summaryrefslogtreecommitdiff
path: root/Libraries/LibJS/Tests/string-spread.js
diff options
context:
space:
mode:
authorMatthew Olsson <matthewcolsson@gmail.com>2020-07-05 10:47:40 -0700
committerAndreas Kling <kling@serenityos.org>2020-07-06 23:40:35 +0200
commit918f4affd51cdd285272770465d4d875f4ae5aa2 (patch)
tree5885d1c4161083454924db9abaaf127c76cf0c99 /Libraries/LibJS/Tests/string-spread.js
parent6d58c48c2fbe2e3ce9b9cfe1dd75a5ccc594f961 (diff)
downloadserenity-918f4affd51cdd285272770465d4d875f4ae5aa2.zip
LibJS: Convert remaining top-level tests to new system
Diffstat (limited to 'Libraries/LibJS/Tests/string-spread.js')
-rw-r--r--Libraries/LibJS/Tests/string-spread.js36
1 files changed, 17 insertions, 19 deletions
diff --git a/Libraries/LibJS/Tests/string-spread.js b/Libraries/LibJS/Tests/string-spread.js
index cca1ab60bf..5443e997eb 100644
--- a/Libraries/LibJS/Tests/string-spread.js
+++ b/Libraries/LibJS/Tests/string-spread.js
@@ -1,27 +1,25 @@
-load("test-common.js");
-
function testArray(arr) {
return arr.length === 4 && arr[0] === "a" && arr[1] === "b" && arr[2] === "c" && arr[3] === "d";
}
-try {
- var arr;
-
- arr = ["a", ..."bc", "d"];
- assert(testArray(arr));
+test("spreading string literal", () => {
+ expect(["a", ..."bc", "d"]).toEqual(["a", "b", "c", "d"]);
+});
- let s = "bc";
- arr = ["a", ...s, "d"];
- assert(testArray(arr));
+test("spreading string variable", () => {
+ const s = "bc";
+ expect(["a", ...s, "d"]).toEqual(["a", "b", "c", "d"]);
+});
- let obj = { a: "bc" };
- arr = ["a", ...obj.a, "d"];
- assert(testArray(arr));
+test("spreading string in object", () => {
+ const obj = { a: "bc" };
+ expect(["a", ...obj.a, "d"]).toEqual(["a", "b", "c", "d"]);
+});
- arr = [..."", ...[...new String("abc")], "d"];
- assert(testArray(arr));
+test("spreading empty string", () => {
+ expect([..."", "a", ..."bc", ..."", "d", ...""]).toEqual(["a", "b", "c", "d"]);
+});
- console.log("PASS");
-} catch (e) {
- console.log("FAIL: " + e);
-}
+test("spreading string objects", () => {
+ expect([..."", ...[...new String("abc")], "d"]).toEqual(["a", "b", "c", "d"]);
+});