61890b15cb
* wip * move print and JSON functions to modules * builtin functions are not replacable now * builtin functions are added for default nil symbol table * importables: builtin modules and source modules * refactoring runtime tests * fix tests * update documentation * cleanup * clean up cli * fix REPL prints
21 lines
726 B
Go
21 lines
726 B
Go
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)
|
|
}
|