2019-01-11 13:27:28 +03:00
|
|
|
package runtime_test
|
2019-01-10 04:26:30 +03:00
|
|
|
|
2019-01-29 00:09:40 +03:00
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/d5/tengo/objects"
|
|
|
|
)
|
2019-01-10 04:26:30 +03:00
|
|
|
|
|
|
|
func TestUndefined(t *testing.T) {
|
2019-03-18 18:15:26 +03:00
|
|
|
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)
|
2019-01-10 04:26:30 +03:00
|
|
|
}
|