Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions tests/object_create_null.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Object.create(null) is an object of no keys that takes any, a dictionary of `any` (TSLANG 222).
function main() {
const o = Object.create(null);
o["k"] = 5;
o["s"] = "t";
assert(o["k"] == 5 && o["s"] == "t", "create(null)");
assert(Object.keys(o).length == 2, "create(null) keys");
console.log("ALL DONE");
}
28 changes: 28 additions & 0 deletions tests/object_define_property_symbol_description.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Object.defineProperty of a dictionary given a literal descriptor of a `value` is `d[k] = value` (writable,
// enumerable and configurable are not kept); `s.description` of a symbol known only at run time is its text
// without `Symbol(` and `)` (TSLANG 222).
function pick(b: boolean): symbol {
return b ? Symbol("a") : Symbol("bb");
}

function defineProperty() {
const d: { [key: string]: number } = {};
const same = Object.defineProperty(d, "x", { value: 42, writable: true });
Object.defineProperty(d, "y", { value: 7 });
assert(d["x"] == 42 && d["y"] == 7 && same["x"] == 42, "defineProperty");
assert(Object.keys(d).join(",") == "x,y", "defineProperty keys");
}

function symbolDescription() {
const r = pick(false);
assert(r.toString() == "Symbol(bb)", "run-time toString");
assert(r.description == "bb" && r.description.length == 2, "run-time description");
const q = pick(true);
assert(q.description == "a", "another run-time description");
}

function main() {
defineProperty();
symbolDescription();
console.log("ALL DONE");
}
Loading