int() bool() and str()
This commit is contained in:
@@ -656,6 +656,28 @@ func TestBuiltinFunctions(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{`pop([1])`, 1},
|
||||
{`bool(1)`, true},
|
||||
{`bool(0)`, false},
|
||||
{`bool(true)`, true},
|
||||
{`bool(false)`, false},
|
||||
{`bool(null)`, false},
|
||||
{`bool("")`, false},
|
||||
{`bool("foo")`, true},
|
||||
{`bool([])`, false},
|
||||
{`bool([1, 2, 3])`, true},
|
||||
{`bool({})`, false},
|
||||
{`bool({"a": 1})`, true},
|
||||
{`int(true)`, 1},
|
||||
{`int(false)`, 0},
|
||||
{`int(1)`, 1},
|
||||
{`int("10")`, 10},
|
||||
{`str(null)`, "null"},
|
||||
{`str(true)`, "true"},
|
||||
{`str(false)`, "false"},
|
||||
{`str(10)`, "10"},
|
||||
{`str("foo")`, "foo"},
|
||||
{`str([1, 2, 3])`, "[1, 2, 3]"},
|
||||
{`str({"a": 1})`, "{\"a\": 1}"},
|
||||
}
|
||||
|
||||
runVmTests(t, tests)
|
||||
|
||||
Reference in New Issue
Block a user