mirror of
https://github.com/robertkrimen/otto
synced 2025-09-28 18:45:22 +08:00
25 lines
460 B
Go
25 lines
460 B
Go
package otto
|
|
|
|
import (
|
|
"testing"
|
|
. "github.com/robertkrimen/terst"
|
|
)
|
|
|
|
func TestOttoError(t *testing.T) {
|
|
Terst(t)
|
|
|
|
Otto := New()
|
|
|
|
_, err := Otto.Run(`throw "Xyzzy"`)
|
|
Is(err, "Xyzzy")
|
|
|
|
_, err = Otto.Run(`throw new TypeError()`)
|
|
Is(err, "TypeError")
|
|
|
|
_, err = Otto.Run(`throw new TypeError("Nothing happens.")`)
|
|
Is(err, "TypeError: Nothing happens.")
|
|
|
|
_, err = ToValue([]byte{})
|
|
Is(err, "TypeError: Unable to convert value: [] ([]uint8)")
|
|
}
|