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-01-29 00:09:40 +03:00
|
|
|
expect(t, `out = undefined`, objects.UndefinedValue)
|
2019-02-10 03:45:21 +03:00
|
|
|
expect(t, `out = undefined.a`, objects.UndefinedValue)
|
|
|
|
expect(t, `out = undefined[1]`, objects.UndefinedValue)
|
|
|
|
expect(t, `out = undefined.a.b`, objects.UndefinedValue)
|
|
|
|
expect(t, `out = undefined[1][2]`, objects.UndefinedValue)
|
|
|
|
expect(t, `out = undefined ? 1 : 2`, 2)
|
2019-01-10 04:26:30 +03:00
|
|
|
expect(t, `out = undefined == undefined`, true)
|
|
|
|
expect(t, `out = undefined == 1`, false)
|
|
|
|
expect(t, `out = 1 == undefined`, false)
|
|
|
|
expect(t, `out = undefined == float([])`, true)
|
|
|
|
expect(t, `out = float([]) == undefined`, true)
|
|
|
|
}
|