Debian Codegraph @

packages/babel-helpers/test/fixtures/behavior/get-with-falsy-receiver/exec.js

raw symbols SCIP
1 // ensure we test the helper implementation,
2 // not built-in Reflect.get to which it defers
3 delete Reflect;
4
5 class Target {
6 get typeOf() {
7 return this === null ? "null" : typeof this;
8 }
9 };
10
11 // check that the 1st argument (target) *is not* used
12 // in place of present but undefined 3rd argument (receiver)
13 expect(HELPER_GET(new Target, "typeOf", undefined)).toBe("undefined");
14
15 // because the helper replaces itself upon invocation,
16 // check it again with nullish arguments
17 expect(HELPER_GET(new Target, "typeOf", undefined)).toBe("undefined");
18 expect(HELPER_GET(new Target, "typeOf", null)).toBe("null");
19
20 // check other falsy types
21 expect(HELPER_GET(new Target, "typeOf", false)).toBe("boolean");
22 expect(HELPER_GET(new Target, "typeOf", 0)).toBe("number");
23 expect(HELPER_GET(new Target, "typeOf", "")).toBe("string");