| 21 | } |
| 22 | |
| 23 | func TestLoadStringSyntaxError(t *testing.T) { |
| 24 | l := NewState() |
| 25 | err := LoadString(l, "this_is_a_syntax_error") |
| 26 | if err != SyntaxError { |
| 27 | t.Error("didn't return SyntaxError on string with syntax error") |
| 28 | } |
| 29 | if l.Top() != 1 { |
| 30 | t.Error("didn't push anything to the stack") |
| 31 | } |
| 32 | if l.IsString(-1) != true { |
| 33 | t.Error("didn't push a string to the stack") |
| 34 | } |
| 35 | estr, _ := l.ToString(-1) |
| 36 | if estr != "[string \"this_is_a_syntax_error\"]:1: syntax error near <eof>" { |
| 37 | t.Error("didn't push the correct error string") |
| 38 | } |
| 39 | } |