12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- package muesli
- import (
- _ "strings"
- "testing"
- )
- func LexText(input string) []Token {
- lexer := NewLexerFromInputString(input)
- tokens := lexer.LexAll()
- return tokens
- }
- func Assert(test *testing.T, ok bool, text string) bool {
- if !ok {
- test.Errorf(text)
- }
- return ok
- }
- func HelperTryLexText(input string, test * testing.T) {
- tokens := LexText(input)
- for i:= 0; i < len(tokens) ; i++ {
- test.Logf("%d: %s", i, tokens[i].String())
- }
- }
- func TestLexing(test *testing.T) {
- const input = `
- greet "hi there"
-
- add 5 10
- mulf -2.0 3.1415
-
- say "hello \"world\\"
- define open a door {
- set (door open) true
- }
- def increment variable by value {
- =variable (add variable $value)
- }
- `
- test.Log("Hi test!")
- HelperTryLexText(input, test)
- }
|