summaryrefslogtreecommitdiff
path: root/Libraries/LibJS/Tests
diff options
context:
space:
mode:
authorLinus Groh <mail@linusgroh.de>2020-04-02 21:16:13 +0100
committerAndreas Kling <kling@serenityos.org>2020-04-03 09:07:05 +0200
commit94afcb54de07499d15fe8e601127148bba022f96 (patch)
tree741131dcb851e9d1e0c6342beaf3d369fcaec6ab /Libraries/LibJS/Tests
parent2636cac6e4705714305fd13e6ac7b0d93f75e225 (diff)
downloadserenity-94afcb54de07499d15fe8e601127148bba022f96.zip
LibJS: Implement Error.prototype.toString()
Diffstat (limited to 'Libraries/LibJS/Tests')
-rw-r--r--Libraries/LibJS/Tests/Error.prototype.toString.js13
1 files changed, 13 insertions, 0 deletions
diff --git a/Libraries/LibJS/Tests/Error.prototype.toString.js b/Libraries/LibJS/Tests/Error.prototype.toString.js
new file mode 100644
index 0000000000..cc0b8185c0
--- /dev/null
+++ b/Libraries/LibJS/Tests/Error.prototype.toString.js
@@ -0,0 +1,13 @@
+function assert(x) { if (!x) throw 1; }
+
+try {
+ assert(Error().toString() === "Error");
+ assert(Error(undefined).toString() === "Error");
+ assert(Error(null).toString() === "Error: null");
+ assert(Error("test").toString() === "Error: test");
+ assert(Error(42).toString() === "Error: 42");
+
+ console.log("PASS");
+} catch (e) {
+ console.log("FAIL: " + e);
+}