summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibJS/Tests/operators/ternary-basic.js
blob: c0f68fdf83144157f9383fb83e0c978c5d74f218 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
test("basic functionality", () => {
    const x = 1;

    expect(x === 1 ? true : false).toBeTrue();
    expect(x ? x : 0).toBe(x);
    expect(1 < 2 ? true : false).toBeTrue();
    expect(0 ? 1 : 1 ? 10 : 20).toBe(10);
    expect(0 ? (1 ? 1 : 10) : 20).toBe(20);
});

test("object values", () => {
    const o = {};
    o.f = true;
    expect(o.f ? true : false).toBeTrue();
    expect(1 ? o.f : null).toBeTrue();
});

test("issue #4409, '?.' followed by decimal digit", () => {
    expect("return false?.1:.2").toEvalTo(0.2);
});