mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-26 22:38:51 +00:00
The addition of assert functions to Userland/js was done before we had load(..) implemented. Now that it exists, it seems like the right move the test helper functions to pure javascript instead of poluting js with random global functions.
29 lines
822 B
JavaScript
29 lines
822 B
JavaScript
load("test-common.js");
|
|
|
|
try {
|
|
var o = { 1: 23, foo: "bar", "hello": "friends" };
|
|
assert(o[1] === 23);
|
|
assert(o["1"] === 23);
|
|
assert(o.foo === "bar");
|
|
assert(o["foo"] === "bar");
|
|
assert(o.hello === "friends");
|
|
assert(o["hello"] === "friends");
|
|
o.baz = "test";
|
|
assert(o.baz === "test");
|
|
assert(o["baz"] === "test");
|
|
o[10] = "123";
|
|
assert(o[10] === "123");
|
|
assert(o["10"] === "123");
|
|
o[-1] = "hello friends";
|
|
assert(o[-1] === "hello friends");
|
|
assert(o["-1"] === "hello friends");
|
|
|
|
var math = { 3.14: "pi" };
|
|
assert(math["3.14"] === "pi");
|
|
// Note : this test doesn't pass yet due to floating-point literals being coerced to i32 on access
|
|
// assert(math[3.14] === "pi");
|
|
|
|
console.log("PASS");
|
|
} catch (e) {
|
|
console.log("FAIL: " + e);
|
|
}
|