1
0
mirror of https://github.com/robertkrimen/otto synced 2025-09-28 18:45:22 +08:00

Fix <return> => <throw>

This commit is contained in:
Robert Krimen 2012-10-07 18:43:56 -07:00
parent 979a87a79d
commit 0681483ac6
2 changed files with 10 additions and 1 deletions

View File

@ -283,7 +283,7 @@ func newThrowNode(argument _node) *_throwNode {
}
func (self _throwNode) String() string {
return fmt.Sprintf("{ <return> %s }", self.Argument)
return fmt.Sprintf("{ <throw> %s }", self.Argument)
}
type _tryCatchNode struct {

View File

@ -629,6 +629,15 @@ func TestParseSuccess(t *testing.T) {
---
{ @ { <var> = abc { <call> { <call> 1 { <function> _ } } _ } } }
`)
test(`
xyzzy
throw new TypeError("Nothing happens.")
---
{ @ xyzzy { <throw> { <new> TypeError "Nothing happens." } } }
`)
}
func TestParseFailure(t *testing.T) {