Files
cell/tests/suite.cm
2025-12-28 13:43:10 -06:00

108 lines
2.6 KiB
Plaintext

return {
test_number_plus_string_throws: function() {
var caught = false
try {
var x = 1 + "hello"
} catch (e) {
caught = true
}
if (!caught) throw "number + string should throw"
},
test_string_plus_number_throws: function() {
var caught = false
try {
var x = "hello" + 1
} catch (e) {
caught = true
}
if (!caught) throw "string + number should throw"
},
test_object_plus_string_throws: function() {
var caught = false
try {
var x = {} + "hello"
} catch (e) {
caught = true
}
if (!caught) throw "object + string should throw"
},
test_string_plus_object_throws: function() {
var caught = false
try {
var x = "hello" + {}
} catch (e) {
caught = true
}
if (!caught) throw "string + object should throw"
},
test_array_plus_string_throws: function() {
var caught = false
try {
var x = [] + "hello"
} catch (e) {
caught = true
}
if (!caught) throw "array + string should throw"
},
test_string_plus_array_throws: function() {
var caught = false
try {
var x = "hello" + []
} catch (e) {
caught = true
}
if (!caught) throw "string + array should throw"
},
test_boolean_plus_string_throws: function() {
var caught = false
try {
var x = true + "hello"
} catch (e) {
caught = true
}
if (!caught) throw "boolean + string should throw"
},
test_string_plus_boolean_throws: function() {
var caught = false
try {
var x = "hello" + false
} catch (e) {
caught = true
}
if (!caught) throw "string + boolean should throw"
},
test_null_plus_string_throws: function() {
var caught = false
try {
var x = null + "hello"
} catch (e) {
caught = true
}
if (!caught) throw "null + string should throw"
},
test_string_plus_null_throws: function() {
var caught = false
try {
var x = "hello" + null
} catch (e) {
caught = true
}
if (!caught) throw "string + null should throw"
},
test_string_plus_string_works: function() {
var x = "hello" + " world"
if (x != "hello world") throw "string + string should work"
}
}