64 lines
2.0 KiB
Plaintext
64 lines
2.0 KiB
Plaintext
// Test all inlined intrinsics
|
|
var arr = [1, 2, 3]
|
|
var rec = {a: 1}
|
|
var fn = function() { return 1 }
|
|
var txt = "hello"
|
|
var num = 42
|
|
var boo = true
|
|
|
|
// is_array
|
|
if (!is_array(arr)) { log.error("FAIL is_array(arr)") }
|
|
if (is_array(rec)) { log.error("FAIL is_array(rec)") }
|
|
if (is_array(42)) { log.error("FAIL is_array(42)") }
|
|
|
|
// is_object
|
|
if (!is_object(rec)) { log.error("FAIL is_object(rec)") }
|
|
if (is_object(arr)) { log.error("FAIL is_object(arr)") }
|
|
if (is_object(42)) { log.error("FAIL is_object(42)") }
|
|
|
|
// is_function
|
|
if (!is_function(fn)) { log.error("FAIL is_function(fn)") }
|
|
if (is_function(rec)) { log.error("FAIL is_function(rec)") }
|
|
|
|
// is_stone
|
|
var frozen = stone([1, 2])
|
|
if (!is_stone(frozen)) { log.error("FAIL is_stone(frozen)") }
|
|
if (is_stone(arr)) { log.error("FAIL is_stone(arr)") }
|
|
if (!is_stone(42)) { log.error("FAIL is_stone(42)") }
|
|
if (!is_stone("hi")) { log.error("FAIL is_stone(str)") }
|
|
|
|
// length
|
|
if (length(arr) != 3) { log.error("FAIL length(arr)") }
|
|
if (length(txt) != 5) { log.error("FAIL length(txt)") }
|
|
if (length([]) != 0) { log.error("FAIL length([])") }
|
|
|
|
// is_integer (already existed but now inlined)
|
|
if (!is_integer(42)) { log.error("FAIL is_integer(42)") }
|
|
if (is_integer(3.14)) { log.error("FAIL is_integer(3.14)") }
|
|
|
|
// is_text
|
|
if (!is_text("hi")) { log.error("FAIL is_text(hi)") }
|
|
if (is_text(42)) { log.error("FAIL is_text(42)") }
|
|
|
|
// is_number
|
|
if (!is_number(42)) { log.error("FAIL is_number(42)") }
|
|
if (!is_number(3.14)) { log.error("FAIL is_number(3.14)") }
|
|
if (is_number("hi")) { log.error("FAIL is_number(hi)") }
|
|
|
|
// is_logical
|
|
if (!is_logical(true)) { log.error("FAIL is_logical(true)") }
|
|
if (is_logical(42)) { log.error("FAIL is_logical(42)") }
|
|
|
|
// is_null
|
|
if (!is_null(null)) { log.error("FAIL is_null(null)") }
|
|
if (is_null(42)) { log.error("FAIL is_null(42)") }
|
|
|
|
// push (inlined)
|
|
var a = [1]
|
|
push(a, 2)
|
|
push(a, 3)
|
|
if (length(a) != 3) { log.error("FAIL push length") }
|
|
if (a[2] != 3) { log.error("FAIL push value") }
|
|
|
|
log.test("all intrinsic tests passed")
|