| 3 | import "testing" |
| 4 | |
| 5 | func TestLoadFileSyntaxError(t *testing.T) { |
| 6 | l := NewState() |
| 7 | err := LoadFile(l, "fixtures/syntax_error.lua", "") |
| 8 | if err != SyntaxError { |
| 9 | t.Error("didn't return SyntaxError on file with syntax error") |
| 10 | } |
| 11 | if l.Top() != 1 { |
| 12 | t.Error("didn't push anything to the stack") |
| 13 | } |
| 14 | if l.IsString(-1) != true { |
| 15 | t.Error("didn't push a string to the stack") |
| 16 | } |
| 17 | estr, _ := l.ToString(-1) |
| 18 | if estr != "fixtures/syntax_error.lua:4: syntax error near <eof>" { |
| 19 | t.Error("didn't push the correct error string") |
| 20 | } |
| 21 | } |
| 22 | |
| 23 | func TestLoadStringSyntaxError(t *testing.T) { |
| 24 | l := NewState() |