From a035e28100aa8e49b7325f5e6a1bc72375f90a48 Mon Sep 17 00:00:00 2001 From: John Alanbrook Date: Sun, 28 Dec 2025 13:43:10 -0600 Subject: [PATCH] string add throw --- tests/suite.cm | 107 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 107 insertions(+) create mode 100644 tests/suite.cm diff --git a/tests/suite.cm b/tests/suite.cm new file mode 100644 index 00000000..e8e1641e --- /dev/null +++ b/tests/suite.cm @@ -0,0 +1,107 @@ +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" + } +}