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

Revert "feat: support null value returns for toValue (#325)" (#417)

This reverts commit 26cb6ccce6.
This commit is contained in:
Steven Hartland 2021-09-27 12:00:52 +01:00 committed by GitHub
parent 26cb6ccce6
commit 209b1fb8e8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 4 additions and 4 deletions

View File

@ -228,7 +228,7 @@ func Test_reflectStruct(t *testing.T) {
test(` test(`
ret = abc.FuncReturn2(); ret = abc.FuncReturn2();
if (ret && ret.length && ret.length == 2 && ret[0] == "def" && ret[1] === null) { if (ret && ret.length && ret.length == 2 && ret[0] == "def" && ret[1] === undefined) {
true; true;
} else { } else {
false; false;

View File

@ -325,7 +325,8 @@ func toValue(value interface{}) Value {
case _result: case _result:
return Value{valueResult, value} return Value{valueResult, value}
case nil: case nil:
return nullValue // TODO Ugh.
return Value{}
case reflect.Value: case reflect.Value:
for value.Kind() == reflect.Ptr { for value.Kind() == reflect.Ptr {
// We were given a pointer, so we'll drill down until we get a non-pointer // We were given a pointer, so we'll drill down until we get a non-pointer

View File

@ -39,8 +39,7 @@ func TestToValue(t *testing.T) {
vm := tester.vm vm := tester.vm
value, _ := vm.ToValue(nil) value, _ := vm.ToValue(nil)
is(value, "null") is(value, "undefined")
is(value, nullValue)
value, _ = vm.ToValue((*byte)(nil)) value, _ = vm.ToValue((*byte)(nil))
is(value, "undefined") is(value, "undefined")