mirror of
https://github.com/robertkrimen/otto
synced 2025-10-12 20:27:30 +08:00

...instead of object. Also, make sure arguments passed through to function are not deletable.
46 lines
860 B
Go
46 lines
860 B
Go
package otto
|
|
|
|
import (
|
|
. "github.com/robertkrimen/terst"
|
|
"testing"
|
|
)
|
|
|
|
func TestFunction_apply(t *testing.T) {
|
|
Terst(t)
|
|
|
|
test := runTest()
|
|
test(`String.prototype.substring.length`, "2")
|
|
test(`String.prototype.substring.apply("abc", [1, 11])`, "bc")
|
|
}
|
|
|
|
func TestFunction_call(t *testing.T) {
|
|
Terst(t)
|
|
|
|
test := runTest()
|
|
test(`String.prototype.substring.length`, "2")
|
|
test(`String.prototype.substring.call("abc", 1, 11)`, "bc")
|
|
}
|
|
|
|
func TestFunctionArguments(t *testing.T) {
|
|
Terst(t)
|
|
|
|
test := runTest()
|
|
// Should not be able to delete arguments
|
|
test(`
|
|
function abc(def, arguments){
|
|
delete def;
|
|
return def;
|
|
}
|
|
abc(1);
|
|
`, "1")
|
|
|
|
// Again, should not be able to delete arguments
|
|
test(`
|
|
function abc(def){
|
|
delete def;
|
|
return def;
|
|
}
|
|
abc(1);
|
|
`, "1")
|
|
}
|