xgo/runtime/vm_undefined_test.go

22 lines
726 B
Go
Raw Normal View History

2019-01-11 13:27:28 +03:00
package runtime_test
import (
"testing"
"github.com/d5/tengo/objects"
)
func TestUndefined(t *testing.T) {
expect(t, `out = undefined`, nil, objects.UndefinedValue)
expect(t, `out = undefined.a`, nil, objects.UndefinedValue)
expect(t, `out = undefined[1]`, nil, objects.UndefinedValue)
expect(t, `out = undefined.a.b`, nil, objects.UndefinedValue)
expect(t, `out = undefined[1][2]`, nil, objects.UndefinedValue)
expect(t, `out = undefined ? 1 : 2`, nil, 2)
expect(t, `out = undefined == undefined`, nil, true)
expect(t, `out = undefined == 1`, nil, false)
expect(t, `out = 1 == undefined`, nil, false)
expect(t, `out = undefined == float([])`, nil, true)
expect(t, `out = float([]) == undefined`, nil, true)
}