// 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)) { print("FAIL is_array(arr)") }
if (is_array(rec)) { print("FAIL is_array(rec)") }
if (is_array(42)) { print("FAIL is_array(42)") }

// is_object
if (!is_object(rec)) { print("FAIL is_object(rec)") }
if (is_object(arr)) { print("FAIL is_object(arr)") }
if (is_object(42)) { print("FAIL is_object(42)") }

// is_function
if (!is_function(fn)) { print("FAIL is_function(fn)") }
if (is_function(rec)) { print("FAIL is_function(rec)") }

// is_stone
var frozen = stone([1, 2])
if (!is_stone(frozen)) { print("FAIL is_stone(frozen)") }
if (is_stone(arr)) { print("FAIL is_stone(arr)") }
if (!is_stone(42)) { print("FAIL is_stone(42)") }
if (!is_stone("hi")) { print("FAIL is_stone(str)") }

// length
if (length(arr) != 3) { print("FAIL length(arr)") }
if (length(txt) != 5) { print("FAIL length(txt)") }
if (length([]) != 0) { print("FAIL length([])") }

// is_integer (already existed but now inlined)
if (!is_integer(42)) { print("FAIL is_integer(42)") }
if (is_integer(3.14)) { print("FAIL is_integer(3.14)") }

// is_text
if (!is_text("hi")) { print("FAIL is_text(hi)") }
if (is_text(42)) { print("FAIL is_text(42)") }

// is_number
if (!is_number(42)) { print("FAIL is_number(42)") }
if (!is_number(3.14)) { print("FAIL is_number(3.14)") }
if (is_number("hi")) { print("FAIL is_number(hi)") }

// is_logical
if (!is_logical(true)) { print("FAIL is_logical(true)") }
if (is_logical(42)) { print("FAIL is_logical(42)") }

// is_null
if (!is_null(null)) { print("FAIL is_null(null)") }
if (is_null(42)) { print("FAIL is_null(42)") }

// push (inlined)
var a = [1]
push(a, 2)
push(a, 3)
if (length(a) != 3) { print("FAIL push length") }
if (a[2] != 3) { print("FAIL push value") }

print("all intrinsic tests passed")
