diff options
Diffstat (limited to 'Godeps/_workspace/src/github.com/robertkrimen/otto/otto_error_test.go')
-rw-r--r-- | Godeps/_workspace/src/github.com/robertkrimen/otto/otto_error_test.go | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/Godeps/_workspace/src/github.com/robertkrimen/otto/otto_error_test.go b/Godeps/_workspace/src/github.com/robertkrimen/otto/otto_error_test.go new file mode 100644 index 000000000..5ce358819 --- /dev/null +++ b/Godeps/_workspace/src/github.com/robertkrimen/otto/otto_error_test.go @@ -0,0 +1,48 @@ +package otto + +import ( + "testing" +) + +func TestOttoError(t *testing.T) { + tt(t, func() { + vm := New() + + _, err := vm.Run(`throw "Xyzzy"`) + is(err, "Xyzzy") + + _, err = vm.Run(`throw new TypeError()`) + is(err, "TypeError") + + _, err = vm.Run(`throw new TypeError("Nothing happens.")`) + is(err, "TypeError: Nothing happens.") + + _, err = ToValue([]byte{}) + is(err, "TypeError: invalid value (slice): missing runtime: [] ([]uint8)") + + _, err = vm.Run(` + (function(){ + return abcdef.length + })() + `) + is(err, "ReferenceError: 'abcdef' is not defined") + + _, err = vm.Run(` + function start() { + } + + start() + + xyzzy() + `) + is(err, "ReferenceError: 'xyzzy' is not defined") + + _, err = vm.Run(` + // Just a comment + + xyzzy + `) + is(err, "ReferenceError: 'xyzzy' is not defined") + + }) +} |