1
0

run npm install to generate a package lock

This commit is contained in:
sashinexists
2024-12-07 13:18:31 +11:00
parent e7d08a91b5
commit 23437d228e
2501 changed files with 290663 additions and 0 deletions

View File

@@ -0,0 +1,58 @@
// Generated tests -- do not edit directly
// @ts-nocheck
import assert from "node:assert";
import { describe } from "node:test";
import oriEval from "../generator/oriEval.js";
describe("conditionalExpression - JavaScript", () => {
assert.strictEqual(true ? 42 : 0, 42, "Condition is true, evaluates and returns the first operand");
assert.strictEqual(false ? 42 : 0, 0, "Condition is false, evaluates and returns the second operand");
assert.strictEqual(1 ? 'yes' : 'no', "yes", "Truthy condition with string operands");
assert.strictEqual(0 ? 'yes' : 'no', "no", "Falsy condition with string operands");
assert.strictEqual('non-empty' ? 1 : 2, 1, "Truthy string condition with numeric operands");
assert.strictEqual('' ? 1 : 2, 2, "Falsy string condition with numeric operands");
assert.strictEqual(null ? 'a' : 'b', "b", "Falsy null condition");
assert.strictEqual(undefined ? 'a' : 'b', "b", "Falsy undefined condition");
assert.strictEqual(NaN ? 'a' : 'b', "b", "Falsy NaN condition");
assert.strictEqual(42 ? true : false, true, "Truthy numeric condition with boolean operands");
assert.strictEqual(0 ? true : false, false, "Falsy numeric condition with boolean operands");
assert.strictEqual([] ? 'array' : 'no array', "array", "Truthy array condition");
assert.strictEqual({} ? 'object' : 'no object', "object", "Truthy object condition");
assert.strictEqual(false ? null : undefined, undefined, "Condition is false, returns undefined");
assert.deepEqual(null ? null : null, null, "Condition is falsy, returns null");
assert.strictEqual(true ? NaN : 42, NaN, "Condition is true, evaluates and returns NaN");
assert.strictEqual((true ? 1 : 2) ? 3 : 4, 3, "Nested ternary where first expression evaluates to 1, which is truthy");
assert.strictEqual((false ? 1 : 2) ? 3 : 4, 3, "Nested ternary where first expression evaluates to 2, which is truthy");
assert.strictEqual((false ? 1 : 0) ? 3 : 4, 4, "Nested ternary where first expression evaluates to 0, which is falsy");
assert.strictEqual(true ? (false ? 10 : 20) : 30, 20, "Nested ternary in the true branch of outer ternary");
assert.strictEqual(false ? (false ? 10 : 20) : 30, 30, "Nested ternary in the false branch of outer ternary");
assert.deepEqual(undefined ? undefined : null, null, "Condition is falsy, returns null");
assert.strictEqual(null ? undefined : undefined, undefined, "Condition is falsy, returns undefined");
});
describe("conditionalExpression - Origami", async() => {
assert.strictEqual(await oriEval("true ? 42 : 0"), 42, "Condition is true, evaluates and returns the first operand");
assert.strictEqual(await oriEval("false ? 42 : 0"), 0, "Condition is false, evaluates and returns the second operand");
assert.strictEqual(await oriEval("1 ? 'yes' : 'no'"), "yes", "Truthy condition with string operands");
assert.strictEqual(await oriEval("0 ? 'yes' : 'no'"), "no", "Falsy condition with string operands");
assert.strictEqual(await oriEval("'non-empty' ? 1 : 2"), 1, "Truthy string condition with numeric operands");
assert.strictEqual(await oriEval("'' ? 1 : 2"), 2, "Falsy string condition with numeric operands");
assert.strictEqual(await oriEval("null ? 'a' : 'b'"), "b", "Falsy null condition");
assert.strictEqual(await oriEval("undefined ? 'a' : 'b'"), "b", "Falsy undefined condition");
assert.strictEqual(await oriEval("NaN ? 'a' : 'b'"), "b", "Falsy NaN condition");
assert.strictEqual(await oriEval("42 ? true : false"), true, "Truthy numeric condition with boolean operands");
assert.strictEqual(await oriEval("0 ? true : false"), false, "Falsy numeric condition with boolean operands");
assert.strictEqual(await oriEval("[] ? 'array' : 'no array'"), "array", "Truthy array condition");
assert.strictEqual(await oriEval("{} ? 'object' : 'no object'"), "object", "Truthy object condition");
assert.strictEqual(await oriEval("false ? null : undefined"), undefined, "Condition is false, returns undefined");
assert.deepEqual(await oriEval("null ? null : null"), null, "Condition is falsy, returns null");
assert.strictEqual(await oriEval("true ? NaN : 42"), NaN, "Condition is true, evaluates and returns NaN");
assert.strictEqual(await oriEval("(true ? 1 : 2) ? 3 : 4"), 3, "Nested ternary where first expression evaluates to 1, which is truthy");
assert.strictEqual(await oriEval("(false ? 1 : 2) ? 3 : 4"), 3, "Nested ternary where first expression evaluates to 2, which is truthy");
assert.strictEqual(await oriEval("(false ? 1 : 0) ? 3 : 4"), 4, "Nested ternary where first expression evaluates to 0, which is falsy");
assert.strictEqual(await oriEval("true ? (false ? 10 : 20) : 30"), 20, "Nested ternary in the true branch of outer ternary");
assert.strictEqual(await oriEval("false ? (false ? 10 : 20) : 30"), 30, "Nested ternary in the false branch of outer ternary");
assert.deepEqual(await oriEval("undefined ? undefined : null"), null, "Condition is falsy, returns null");
assert.strictEqual(await oriEval("null ? undefined : undefined"), undefined, "Condition is falsy, returns undefined");
});

View File

@@ -0,0 +1,80 @@
// Generated tests -- do not edit directly
// @ts-nocheck
import assert from "node:assert";
import { describe } from "node:test";
import oriEval from "../generator/oriEval.js";
describe("logicalAndExpression - JavaScript", () => {
assert.strictEqual(true && true, true, "Both operands are true");
assert.strictEqual(true && false, false, "First operand is true, second is false");
assert.strictEqual(false && true, false, "First operand is false, second is true");
assert.strictEqual(false && false, false, "Both operands are false");
assert.strictEqual(false && (1 / 0), false, "Short-circuit evaluation: first operand false, second not evaluated");
assert.strictEqual(true && 42, 42, "Short-circuit evaluation: first operand true, evaluates second");
assert.strictEqual(0 && true, 0, "Short-circuiting with falsy value (0)");
assert.strictEqual(true && 'string', "string", "Truthy value with string");
assert.strictEqual(false && 'string', false, "Falsy value with string");
assert.strictEqual(1 && 0, 0, "Truthy numeric value with falsy numeric value");
assert.strictEqual(0 && 1, 0, "Falsy numeric value with truthy numeric value");
assert.strictEqual('' && 'non-empty string', "", "Falsy string value with truthy string");
assert.strictEqual('non-empty string' && '', "", "Truthy string with falsy string");
assert.strictEqual({} && true, true, "Empty object as first operand");
assert.deepEqual(true && {}, {}, "Empty object as second operand");
assert.strictEqual([] && true, true, "Array as first operand");
assert.deepEqual(true && [], [], "Array as second operand");
assert.deepEqual(null && true, null, "Null as first operand");
assert.deepEqual(true && null, null, "Null as second operand");
assert.strictEqual(undefined && true, undefined, "Undefined as first operand");
assert.strictEqual(true && undefined, undefined, "Undefined as second operand");
assert.strictEqual(NaN && true, NaN, "NaN as first operand");
assert.strictEqual(true && NaN, NaN, "NaN as second operand");
assert.strictEqual((true && false) && true, false, "Nested logical ANDs with a false in the middle");
assert.strictEqual((true && true) && true, true, "Nested logical ANDs with all true");
assert.strictEqual(true && (true && false), false, "Nested logical ANDs with false in inner");
assert.strictEqual((true && (false && true)), false, "Complex nesting with false at inner-most");
assert.strictEqual(true && (3 || 0), 3, "Logical AND with logical OR");
assert.strictEqual(true && (0 || 3), 3, "Logical AND with logical OR and falsy values");
assert.strictEqual('' && false, "", "Falsy string and false");
assert.strictEqual(false && '', false, "False and falsy string");
assert.strictEqual(undefined && null, undefined, "Undefined and null");
assert.deepEqual(null && undefined, null, "Null and undefined");
assert.strictEqual((false && true) && undefined, false, "Short-circuiting nested AND with undefined");
});
describe("logicalAndExpression - Origami", async() => {
assert.strictEqual(await oriEval("true && true"), true, "Both operands are true");
assert.strictEqual(await oriEval("true && false"), false, "First operand is true, second is false");
assert.strictEqual(await oriEval("false && true"), false, "First operand is false, second is true");
assert.strictEqual(await oriEval("false && false"), false, "Both operands are false");
assert.strictEqual(await oriEval("false && (1 / 0)"), false, "Short-circuit evaluation: first operand false, second not evaluated");
assert.strictEqual(await oriEval("true && 42"), 42, "Short-circuit evaluation: first operand true, evaluates second");
assert.strictEqual(await oriEval("0 && true"), 0, "Short-circuiting with falsy value (0)");
assert.strictEqual(await oriEval("true && 'string'"), "string", "Truthy value with string");
assert.strictEqual(await oriEval("false && 'string'"), false, "Falsy value with string");
assert.strictEqual(await oriEval("1 && 0"), 0, "Truthy numeric value with falsy numeric value");
assert.strictEqual(await oriEval("0 && 1"), 0, "Falsy numeric value with truthy numeric value");
assert.strictEqual(await oriEval("'' && 'non-empty string'"), "", "Falsy string value with truthy string");
assert.strictEqual(await oriEval("'non-empty string' && ''"), "", "Truthy string with falsy string");
assert.strictEqual(await oriEval("{} && true"), true, "Empty object as first operand");
assert.deepEqual(await oriEval("true && {}"), {}, "Empty object as second operand");
assert.strictEqual(await oriEval("[] && true"), true, "Array as first operand");
assert.deepEqual(await oriEval("true && []"), [], "Array as second operand");
assert.deepEqual(await oriEval("null && true"), null, "Null as first operand");
assert.deepEqual(await oriEval("true && null"), null, "Null as second operand");
assert.strictEqual(await oriEval("undefined && true"), undefined, "Undefined as first operand");
assert.strictEqual(await oriEval("true && undefined"), undefined, "Undefined as second operand");
assert.strictEqual(await oriEval("NaN && true"), NaN, "NaN as first operand");
assert.strictEqual(await oriEval("true && NaN"), NaN, "NaN as second operand");
assert.strictEqual(await oriEval("(true && false) && true"), false, "Nested logical ANDs with a false in the middle");
assert.strictEqual(await oriEval("(true && true) && true"), true, "Nested logical ANDs with all true");
assert.strictEqual(await oriEval("true && (true && false)"), false, "Nested logical ANDs with false in inner");
assert.strictEqual(await oriEval("(true && (false && true))"), false, "Complex nesting with false at inner-most");
assert.strictEqual(await oriEval("true && (3 || 0)"), 3, "Logical AND with logical OR");
assert.strictEqual(await oriEval("true && (0 || 3)"), 3, "Logical AND with logical OR and falsy values");
assert.strictEqual(await oriEval("'' && false"), "", "Falsy string and false");
assert.strictEqual(await oriEval("false && ''"), false, "False and falsy string");
assert.strictEqual(await oriEval("undefined && null"), undefined, "Undefined and null");
assert.deepEqual(await oriEval("null && undefined"), null, "Null and undefined");
assert.strictEqual(await oriEval("(false && true) && undefined"), false, "Short-circuiting nested AND with undefined");
});

View File

@@ -0,0 +1,78 @@
// Generated tests -- do not edit directly
// @ts-nocheck
import assert from "node:assert";
import { describe } from "node:test";
import oriEval from "../generator/oriEval.js";
describe("logicalOrExpression - JavaScript", () => {
assert.strictEqual(true || true, true, "Both operands are true");
assert.strictEqual(true || false, true, "First operand is true, second is false");
assert.strictEqual(false || true, true, "First operand is false, second is true");
assert.strictEqual(false || false, false, "Both operands are false");
assert.strictEqual(false || 42, 42, "Short-circuit evaluation: first operand false, evaluates second");
assert.strictEqual(0 || true, true, "Falsy value (0) with truthy second operand");
assert.strictEqual(true || 'string', true, "Truthy first operand, string second operand not evaluated");
assert.strictEqual(false || 'string', "string", "Falsy first operand, evaluates string second operand");
assert.strictEqual(1 || 0, 1, "Truthy numeric value with falsy numeric value");
assert.strictEqual(0 || 1, 1, "Falsy numeric value with truthy numeric value");
assert.strictEqual('' || 'non-empty string', "non-empty string", "Falsy string value with truthy string");
assert.strictEqual('non-empty string' || '', "non-empty string", "Truthy string with falsy string");
assert.deepEqual({} || true, {}, "Empty object as first operand");
assert.strictEqual(true || {}, true, "True as first operand, object not evaluated");
assert.deepEqual([] || true, [], "Array as first operand");
assert.strictEqual(true || [], true, "True as first operand, array not evaluated");
assert.strictEqual(null || true, true, "Null as first operand");
assert.strictEqual(true || null, true, "True as first operand, null not evaluated");
assert.strictEqual(undefined || true, true, "Undefined as first operand");
assert.strictEqual(true || undefined, true, "True as first operand, undefined not evaluated");
assert.strictEqual(NaN || true, true, "NaN as first operand");
assert.strictEqual(true || NaN, true, "True as first operand, NaN not evaluated");
assert.strictEqual((false || true) || false, true, "Nested logical ORs with a true in the middle");
assert.strictEqual((false || false) || true, true, "Nested logical ORs with a true at the end");
assert.strictEqual(false || (false || true), true, "Nested logical ORs with true in inner");
assert.strictEqual((false || (true || false)), true, "Complex nesting with true at inner-most");
assert.strictEqual(false || (3 && 0), 0, "Logical OR with logical AND and falsy result");
assert.strictEqual(false || (0 && 3), 0, "Logical OR with logical AND and falsy first operand");
assert.strictEqual('' || false, false, "Falsy string and false");
assert.strictEqual(false || '', "", "False and falsy string");
assert.deepEqual(undefined || null, null, "Undefined and null");
assert.strictEqual(null || undefined, undefined, "Null and undefined");
assert.strictEqual((true || false) || undefined, true, "Short-circuiting nested OR with undefined");
});
describe("logicalOrExpression - Origami", async() => {
assert.strictEqual(await oriEval("true || true"), true, "Both operands are true");
assert.strictEqual(await oriEval("true || false"), true, "First operand is true, second is false");
assert.strictEqual(await oriEval("false || true"), true, "First operand is false, second is true");
assert.strictEqual(await oriEval("false || false"), false, "Both operands are false");
assert.strictEqual(await oriEval("false || 42"), 42, "Short-circuit evaluation: first operand false, evaluates second");
assert.strictEqual(await oriEval("0 || true"), true, "Falsy value (0) with truthy second operand");
assert.strictEqual(await oriEval("true || 'string'"), true, "Truthy first operand, string second operand not evaluated");
assert.strictEqual(await oriEval("false || 'string'"), "string", "Falsy first operand, evaluates string second operand");
assert.strictEqual(await oriEval("1 || 0"), 1, "Truthy numeric value with falsy numeric value");
assert.strictEqual(await oriEval("0 || 1"), 1, "Falsy numeric value with truthy numeric value");
assert.strictEqual(await oriEval("'' || 'non-empty string'"), "non-empty string", "Falsy string value with truthy string");
assert.strictEqual(await oriEval("'non-empty string' || ''"), "non-empty string", "Truthy string with falsy string");
assert.deepEqual(await oriEval("{} || true"), {}, "Empty object as first operand");
assert.strictEqual(await oriEval("true || {}"), true, "True as first operand, object not evaluated");
assert.deepEqual(await oriEval("[] || true"), [], "Array as first operand");
assert.strictEqual(await oriEval("true || []"), true, "True as first operand, array not evaluated");
assert.strictEqual(await oriEval("null || true"), true, "Null as first operand");
assert.strictEqual(await oriEval("true || null"), true, "True as first operand, null not evaluated");
assert.strictEqual(await oriEval("undefined || true"), true, "Undefined as first operand");
assert.strictEqual(await oriEval("true || undefined"), true, "True as first operand, undefined not evaluated");
assert.strictEqual(await oriEval("NaN || true"), true, "NaN as first operand");
assert.strictEqual(await oriEval("true || NaN"), true, "True as first operand, NaN not evaluated");
assert.strictEqual(await oriEval("(false || true) || false"), true, "Nested logical ORs with a true in the middle");
assert.strictEqual(await oriEval("(false || false) || true"), true, "Nested logical ORs with a true at the end");
assert.strictEqual(await oriEval("false || (false || true)"), true, "Nested logical ORs with true in inner");
assert.strictEqual(await oriEval("(false || (true || false))"), true, "Complex nesting with true at inner-most");
assert.strictEqual(await oriEval("false || (3 && 0)"), 0, "Logical OR with logical AND and falsy result");
assert.strictEqual(await oriEval("false || (0 && 3)"), 0, "Logical OR with logical AND and falsy first operand");
assert.strictEqual(await oriEval("'' || false"), false, "Falsy string and false");
assert.strictEqual(await oriEval("false || ''"), "", "False and falsy string");
assert.deepEqual(await oriEval("undefined || null"), null, "Undefined and null");
assert.strictEqual(await oriEval("null || undefined"), undefined, "Null and undefined");
assert.strictEqual(await oriEval("(true || false) || undefined"), true, "Short-circuiting nested OR with undefined");
});

View File

@@ -0,0 +1,64 @@
// Generated tests -- do not edit directly
// @ts-nocheck
import assert from "node:assert";
import { describe } from "node:test";
import oriEval from "../generator/oriEval.js";
describe("nullishCoalescingExpression - JavaScript", () => {
assert.strictEqual(null ?? 42, 42, "Left operand is null, returns right operand");
assert.strictEqual(undefined ?? 42, 42, "Left operand is undefined, returns right operand");
assert.strictEqual(0 ?? 42, 0, "Left operand is 0 (falsy but not nullish), returns left operand");
assert.strictEqual('' ?? 'default', "", "Left operand is an empty string (falsy but not nullish), returns left operand");
assert.strictEqual(false ?? true, false, "Left operand is false (falsy but not nullish), returns left operand");
assert.strictEqual(42 ?? 0, 42, "Left operand is a non-nullish truthy value, returns left operand");
assert.strictEqual(null ?? undefined, undefined, "Left operand is null, returns right operand which is undefined");
assert.deepEqual(undefined ?? null, null, "Left operand is undefined, returns right operand which is null");
assert.strictEqual(NaN ?? 42, NaN, "Left operand is NaN (not nullish), returns left operand");
assert.deepEqual([] ?? 'default', [], "Left operand is an empty array (not nullish), returns left operand");
assert.deepEqual({} ?? 'default', {}, "Left operand is an empty object (not nullish), returns left operand");
assert.strictEqual((null ?? 42) ?? 50, 42, "Nested nullish coalescing, first nullish operand replaced, second ignored");
assert.strictEqual((undefined ?? null) ?? 'fallback', "fallback", "Nested nullish coalescing");
assert.strictEqual((0 ?? null) ?? 'fallback', 0, "Nested nullish coalescing with falsy but non-nullish value");
assert.strictEqual(null ?? (undefined ?? 42), 42, "Nullish coalescing in the right operand");
assert.strictEqual(null ?? null ?? null ?? 'fallback', "fallback", "Chained nullish coalescing, resolves to the last non-nullish value");
assert.strictEqual(null ?? (false ?? 'default'), false, "Right operand evaluates to non-nullish falsy value");
assert.strictEqual(null ?? (true ?? 'default'), true, "Right operand evaluates to truthy value");
assert.strictEqual(42 ?? (null ?? 0), 42, "Left operand is not nullish, ignores right operand");
assert.strictEqual(undefined ?? null ?? 'value', "value", "Chained nullish coalescing with undefined and null");
assert.strictEqual((NaN ?? null) ?? 42, NaN, "Left operand is NaN, not nullish, returns NaN");
assert.strictEqual((undefined ?? NaN) ?? 42, NaN, "Right operand resolves to NaN");
assert.strictEqual(null ?? 'default' ?? 42, "default", "Chained nullish coalescing, resolves to first non-nullish value");
assert.strictEqual('' ?? 'default' ?? 42, "", "Falsy but non-nullish value, returns left operand");
assert.strictEqual(null ?? undefined ?? NaN, NaN, "Chained nullish coalescing, resolves to NaN as the first non-nullish value");
assert.strictEqual((null ?? null) ?? undefined, undefined, "Nested nullish coalescing resolves to undefined");
});
describe("nullishCoalescingExpression - Origami", async() => {
assert.strictEqual(await oriEval("null ?? 42"), 42, "Left operand is null, returns right operand");
assert.strictEqual(await oriEval("undefined ?? 42"), 42, "Left operand is undefined, returns right operand");
assert.strictEqual(await oriEval("0 ?? 42"), 0, "Left operand is 0 (falsy but not nullish), returns left operand");
assert.strictEqual(await oriEval("'' ?? 'default'"), "", "Left operand is an empty string (falsy but not nullish), returns left operand");
assert.strictEqual(await oriEval("false ?? true"), false, "Left operand is false (falsy but not nullish), returns left operand");
assert.strictEqual(await oriEval("42 ?? 0"), 42, "Left operand is a non-nullish truthy value, returns left operand");
assert.strictEqual(await oriEval("null ?? undefined"), undefined, "Left operand is null, returns right operand which is undefined");
assert.deepEqual(await oriEval("undefined ?? null"), null, "Left operand is undefined, returns right operand which is null");
assert.strictEqual(await oriEval("NaN ?? 42"), NaN, "Left operand is NaN (not nullish), returns left operand");
assert.deepEqual(await oriEval("[] ?? 'default'"), [], "Left operand is an empty array (not nullish), returns left operand");
assert.deepEqual(await oriEval("{} ?? 'default'"), {}, "Left operand is an empty object (not nullish), returns left operand");
assert.strictEqual(await oriEval("(null ?? 42) ?? 50"), 42, "Nested nullish coalescing, first nullish operand replaced, second ignored");
assert.strictEqual(await oriEval("(undefined ?? null) ?? 'fallback'"), "fallback", "Nested nullish coalescing");
assert.strictEqual(await oriEval("(0 ?? null) ?? 'fallback'"), 0, "Nested nullish coalescing with falsy but non-nullish value");
assert.strictEqual(await oriEval("null ?? (undefined ?? 42)"), 42, "Nullish coalescing in the right operand");
assert.strictEqual(await oriEval("null ?? null ?? null ?? 'fallback'"), "fallback", "Chained nullish coalescing, resolves to the last non-nullish value");
assert.strictEqual(await oriEval("null ?? (false ?? 'default')"), false, "Right operand evaluates to non-nullish falsy value");
assert.strictEqual(await oriEval("null ?? (true ?? 'default')"), true, "Right operand evaluates to truthy value");
assert.strictEqual(await oriEval("42 ?? (null ?? 0)"), 42, "Left operand is not nullish, ignores right operand");
assert.strictEqual(await oriEval("undefined ?? null ?? 'value'"), "value", "Chained nullish coalescing with undefined and null");
assert.strictEqual(await oriEval("(NaN ?? null) ?? 42"), NaN, "Left operand is NaN, not nullish, returns NaN");
assert.strictEqual(await oriEval("(undefined ?? NaN) ?? 42"), NaN, "Right operand resolves to NaN");
assert.strictEqual(await oriEval("null ?? 'default' ?? 42"), "default", "Chained nullish coalescing, resolves to first non-nullish value");
assert.strictEqual(await oriEval("'' ?? 'default' ?? 42"), "", "Falsy but non-nullish value, returns left operand");
assert.strictEqual(await oriEval("null ?? undefined ?? NaN"), NaN, "Chained nullish coalescing, resolves to NaN as the first non-nullish value");
assert.strictEqual(await oriEval("(null ?? null) ?? undefined"), undefined, "Nested nullish coalescing resolves to undefined");
});