forked from sashin/sashinexists
run npm install to generate a package lock
This commit is contained in:
1
node_modules/@weborigami/language/test/cases/ReadMe.md
generated
vendored
Normal file
1
node_modules/@weborigami/language/test/cases/ReadMe.md
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
This folder defines expression tests in YAML files so that we can programmatically test the evaluation of the expressions in both JavaScript and Origami.
|
||||
101
node_modules/@weborigami/language/test/cases/conditionalExpression.yaml
generated
vendored
Normal file
101
node_modules/@weborigami/language/test/cases/conditionalExpression.yaml
generated
vendored
Normal file
@@ -0,0 +1,101 @@
|
||||
# Conditional (ternary) expression tests
|
||||
|
||||
- source: "true ? 42 : 0"
|
||||
expected: 42
|
||||
description: "Condition is true, evaluates and returns the first operand"
|
||||
|
||||
- source: "false ? 42 : 0"
|
||||
expected: 0
|
||||
description: "Condition is false, evaluates and returns the second operand"
|
||||
|
||||
- source: "1 ? 'yes' : 'no'"
|
||||
expected: "yes"
|
||||
description: "Truthy condition with string operands"
|
||||
|
||||
- source: "0 ? 'yes' : 'no'"
|
||||
expected: "no"
|
||||
description: "Falsy condition with string operands"
|
||||
|
||||
- source: "'non-empty' ? 1 : 2"
|
||||
expected: 1
|
||||
description: "Truthy string condition with numeric operands"
|
||||
|
||||
- source: "'' ? 1 : 2"
|
||||
expected: 2
|
||||
description: "Falsy string condition with numeric operands"
|
||||
|
||||
- source: "null ? 'a' : 'b'"
|
||||
expected: "b"
|
||||
description: "Falsy null condition"
|
||||
|
||||
- source: "undefined ? 'a' : 'b'"
|
||||
expected: "b"
|
||||
description: "Falsy undefined condition"
|
||||
|
||||
- source: "NaN ? 'a' : 'b'"
|
||||
expected: "b"
|
||||
description: "Falsy NaN condition"
|
||||
|
||||
- source: "42 ? true : false"
|
||||
expected: true
|
||||
description: "Truthy numeric condition with boolean operands"
|
||||
|
||||
- source: "0 ? true : false"
|
||||
expected: false
|
||||
description: "Falsy numeric condition with boolean operands"
|
||||
|
||||
- source: "[] ? 'array' : 'no array'"
|
||||
expected: "array"
|
||||
description: "Truthy array condition"
|
||||
|
||||
- source: "{} ? 'object' : 'no object'"
|
||||
expected: "object"
|
||||
description: "Truthy object condition"
|
||||
|
||||
- source: "false ? null : undefined"
|
||||
expected: __undefined__
|
||||
description: "Condition is false, returns undefined"
|
||||
|
||||
- source: "null ? null : null"
|
||||
expected: __null__
|
||||
description: "Condition is falsy, returns null"
|
||||
|
||||
- source: "true ? NaN : 42"
|
||||
expected: __NaN__
|
||||
description: "Condition is true, evaluates and returns NaN"
|
||||
|
||||
- source: "(true ? 1 : 2) ? 3 : 4"
|
||||
expected: 3
|
||||
description: "Nested ternary where first expression evaluates to 1, which is truthy"
|
||||
|
||||
- source: "(false ? 1 : 2) ? 3 : 4"
|
||||
expected: 3
|
||||
description: "Nested ternary where first expression evaluates to 2, which is truthy"
|
||||
|
||||
- source: "(false ? 1 : 0) ? 3 : 4"
|
||||
expected: 4
|
||||
description: "Nested ternary where first expression evaluates to 0, which is falsy"
|
||||
|
||||
- source: "true ? (false ? 10 : 20) : 30"
|
||||
expected: 20
|
||||
description: "Nested ternary in the true branch of outer ternary"
|
||||
|
||||
- source: "false ? (false ? 10 : 20) : 30"
|
||||
expected: 30
|
||||
description: "Nested ternary in the false branch of outer ternary"
|
||||
|
||||
# - source: "'truthy' ? 1 + 2 : 3 + 4"
|
||||
# expected: 3
|
||||
# description: "Evaluates and returns the true branch with an arithmetic expression"
|
||||
|
||||
# - source: "'' ? 1 + 2 : 3 + 4"
|
||||
# expected: 7
|
||||
# description: "Evaluates and returns the false branch with an arithmetic expression"
|
||||
|
||||
- source: "undefined ? undefined : null"
|
||||
expected: __null__
|
||||
description: "Condition is falsy, returns null"
|
||||
|
||||
- source: "null ? undefined : undefined"
|
||||
expected: __undefined__
|
||||
description: "Condition is falsy, returns undefined"
|
||||
146
node_modules/@weborigami/language/test/cases/logicalAndExpression.yaml
generated
vendored
Normal file
146
node_modules/@weborigami/language/test/cases/logicalAndExpression.yaml
generated
vendored
Normal file
@@ -0,0 +1,146 @@
|
||||
# Logical AND expression tests
|
||||
|
||||
- source: "true && true"
|
||||
expected: true
|
||||
description: "Both operands are true"
|
||||
|
||||
- source: "true && false"
|
||||
expected: false
|
||||
description: "First operand is true, second is false"
|
||||
|
||||
- source: "false && true"
|
||||
expected: false
|
||||
description: "First operand is false, second is true"
|
||||
|
||||
- source: "false && false"
|
||||
expected: false
|
||||
description: "Both operands are false"
|
||||
|
||||
- source: "false && (1 / 0)"
|
||||
expected: false
|
||||
description: "Short-circuit evaluation: first operand false, second not evaluated"
|
||||
|
||||
- source: "true && 42"
|
||||
expected: 42
|
||||
description: "Short-circuit evaluation: first operand true, evaluates second"
|
||||
|
||||
- source: "0 && true"
|
||||
expected: 0
|
||||
description: "Short-circuiting with falsy value (0)"
|
||||
|
||||
- source: "true && 'string'"
|
||||
expected: "string"
|
||||
description: "Truthy value with string"
|
||||
|
||||
- source: "false && 'string'"
|
||||
expected: false
|
||||
description: "Falsy value with string"
|
||||
|
||||
- source: "1 && 0"
|
||||
expected: 0
|
||||
description: "Truthy numeric value with falsy numeric value"
|
||||
|
||||
- source: "0 && 1"
|
||||
expected: 0
|
||||
description: "Falsy numeric value with truthy numeric value"
|
||||
|
||||
- source: "'' && 'non-empty string'"
|
||||
expected: ""
|
||||
description: "Falsy string value with truthy string"
|
||||
|
||||
- source: "'non-empty string' && ''"
|
||||
expected: ""
|
||||
description: "Truthy string with falsy string"
|
||||
|
||||
- source: "{} && true"
|
||||
expected: true
|
||||
description: "Empty object as first operand"
|
||||
|
||||
- source: "true && {}"
|
||||
expected: {}
|
||||
description: "Empty object as second operand"
|
||||
|
||||
- source: "[] && true"
|
||||
expected: true
|
||||
description: "Array as first operand"
|
||||
|
||||
- source: "true && []"
|
||||
expected: []
|
||||
description: "Array as second operand"
|
||||
|
||||
- source: "null && true"
|
||||
expected: null
|
||||
description: "Null as first operand"
|
||||
|
||||
- source: "true && null"
|
||||
expected: null
|
||||
description: "Null as second operand"
|
||||
|
||||
- source: "undefined && true"
|
||||
expected: __undefined__
|
||||
description: "Undefined as first operand"
|
||||
|
||||
- source: "true && undefined"
|
||||
expected: __undefined__
|
||||
description: "Undefined as second operand"
|
||||
|
||||
- source: "NaN && true"
|
||||
expected: __NaN__
|
||||
description: "NaN as first operand"
|
||||
|
||||
- source: "true && NaN"
|
||||
expected: __NaN__
|
||||
description: "NaN as second operand"
|
||||
|
||||
- source: "(true && false) && true"
|
||||
expected: false
|
||||
description: "Nested logical ANDs with a false in the middle"
|
||||
|
||||
- source: "(true && true) && true"
|
||||
expected: true
|
||||
description: "Nested logical ANDs with all true"
|
||||
|
||||
- source: "true && (true && false)"
|
||||
expected: false
|
||||
description: "Nested logical ANDs with false in inner"
|
||||
|
||||
- source: "(true && (false && true))"
|
||||
expected: false
|
||||
description: "Complex nesting with false at inner-most"
|
||||
|
||||
# TODO: Uncomment when we can do math
|
||||
# - source: "true && (1 + 1 === 2)"
|
||||
# expected: true
|
||||
# description: "Combines logical AND with equality comparison"
|
||||
|
||||
# - source: "false && (5 > 2)"
|
||||
# expected: false
|
||||
# description: "Logical AND with greater-than comparison"
|
||||
|
||||
- source: "true && (3 || 0)"
|
||||
expected: 3
|
||||
description: "Logical AND with logical OR"
|
||||
|
||||
- source: "true && (0 || 3)"
|
||||
expected: 3
|
||||
description: "Logical AND with logical OR and falsy values"
|
||||
|
||||
- source: "'' && false"
|
||||
expected: ""
|
||||
description: "Falsy string and false"
|
||||
|
||||
- source: "false && ''"
|
||||
expected: false
|
||||
description: "False and falsy string"
|
||||
|
||||
- source: "undefined && null"
|
||||
expected: __undefined__
|
||||
description: "Undefined and null"
|
||||
|
||||
- source: "null && undefined"
|
||||
expected: null
|
||||
description: "Null and undefined"
|
||||
|
||||
- source: "(false && true) && undefined"
|
||||
expected: false
|
||||
description: "Short-circuiting nested AND with undefined"
|
||||
145
node_modules/@weborigami/language/test/cases/logicalOrExpression.yaml
generated
vendored
Normal file
145
node_modules/@weborigami/language/test/cases/logicalOrExpression.yaml
generated
vendored
Normal file
@@ -0,0 +1,145 @@
|
||||
# Logical OR expression tests
|
||||
|
||||
- source: "true || true"
|
||||
expected: true
|
||||
description: "Both operands are true"
|
||||
|
||||
- source: "true || false"
|
||||
expected: true
|
||||
description: "First operand is true, second is false"
|
||||
|
||||
- source: "false || true"
|
||||
expected: true
|
||||
description: "First operand is false, second is true"
|
||||
|
||||
- source: "false || false"
|
||||
expected: false
|
||||
description: "Both operands are false"
|
||||
|
||||
# - source: "true || (1 / 0)"
|
||||
# expected: true
|
||||
# description: "Short-circuit evaluation: first operand true, second not evaluated"
|
||||
|
||||
- source: "false || 42"
|
||||
expected: 42
|
||||
description: "Short-circuit evaluation: first operand false, evaluates second"
|
||||
|
||||
- source: "0 || true"
|
||||
expected: true
|
||||
description: "Falsy value (0) with truthy second operand"
|
||||
|
||||
- source: "true || 'string'"
|
||||
expected: true
|
||||
description: "Truthy first operand, string second operand not evaluated"
|
||||
|
||||
- source: "false || 'string'"
|
||||
expected: "string"
|
||||
description: "Falsy first operand, evaluates string second operand"
|
||||
|
||||
- source: "1 || 0"
|
||||
expected: 1
|
||||
description: "Truthy numeric value with falsy numeric value"
|
||||
|
||||
- source: "0 || 1"
|
||||
expected: 1
|
||||
description: "Falsy numeric value with truthy numeric value"
|
||||
|
||||
- source: "'' || 'non-empty string'"
|
||||
expected: "non-empty string"
|
||||
description: "Falsy string value with truthy string"
|
||||
|
||||
- source: "'non-empty string' || ''"
|
||||
expected: "non-empty string"
|
||||
description: "Truthy string with falsy string"
|
||||
|
||||
- source: "{} || true"
|
||||
expected: {}
|
||||
description: "Empty object as first operand"
|
||||
|
||||
- source: "true || {}"
|
||||
expected: true
|
||||
description: "True as first operand, object not evaluated"
|
||||
|
||||
- source: "[] || true"
|
||||
expected: []
|
||||
description: "Array as first operand"
|
||||
|
||||
- source: "true || []"
|
||||
expected: true
|
||||
description: "True as first operand, array not evaluated"
|
||||
|
||||
- source: "null || true"
|
||||
expected: true
|
||||
description: "Null as first operand"
|
||||
|
||||
- source: "true || null"
|
||||
expected: true
|
||||
description: "True as first operand, null not evaluated"
|
||||
|
||||
- source: "undefined || true"
|
||||
expected: true
|
||||
description: "Undefined as first operand"
|
||||
|
||||
- source: "true || undefined"
|
||||
expected: true
|
||||
description: "True as first operand, undefined not evaluated"
|
||||
|
||||
- source: "NaN || true"
|
||||
expected: true
|
||||
description: "NaN as first operand"
|
||||
|
||||
- source: "true || NaN"
|
||||
expected: true
|
||||
description: "True as first operand, NaN not evaluated"
|
||||
|
||||
- source: "(false || true) || false"
|
||||
expected: true
|
||||
description: "Nested logical ORs with a true in the middle"
|
||||
|
||||
- source: "(false || false) || true"
|
||||
expected: true
|
||||
description: "Nested logical ORs with a true at the end"
|
||||
|
||||
- source: "false || (false || true)"
|
||||
expected: true
|
||||
description: "Nested logical ORs with true in inner"
|
||||
|
||||
- source: "(false || (true || false))"
|
||||
expected: true
|
||||
description: "Complex nesting with true at inner-most"
|
||||
|
||||
# - source: "true || (1 + 1 === 2)"
|
||||
# expected: true
|
||||
# description: "Combines logical OR with equality comparison"
|
||||
|
||||
# - source: "false || (5 > 2)"
|
||||
# expected: true
|
||||
# description: "Logical OR with greater-than comparison"
|
||||
|
||||
- source: "false || (3 && 0)"
|
||||
expected: 0
|
||||
description: "Logical OR with logical AND and falsy result"
|
||||
|
||||
- source: "false || (0 && 3)"
|
||||
expected: 0
|
||||
description: "Logical OR with logical AND and falsy first operand"
|
||||
|
||||
- source: "'' || false"
|
||||
expected: false
|
||||
description: "Falsy string and false"
|
||||
|
||||
- source: "false || ''"
|
||||
expected: ""
|
||||
description: "False and falsy string"
|
||||
|
||||
- source: "undefined || null"
|
||||
expected: __null__
|
||||
description: "Undefined and null"
|
||||
|
||||
- source: "null || undefined"
|
||||
expected: __undefined__
|
||||
description: "Null and undefined"
|
||||
|
||||
- source: "(true || false) || undefined"
|
||||
expected: true
|
||||
description: "Short-circuiting nested OR with undefined"
|
||||
105
node_modules/@weborigami/language/test/cases/nullishCoalescingExpression.yaml
generated
vendored
Normal file
105
node_modules/@weborigami/language/test/cases/nullishCoalescingExpression.yaml
generated
vendored
Normal file
@@ -0,0 +1,105 @@
|
||||
# Nullish coalescing expression tests
|
||||
|
||||
- source: "null ?? 42"
|
||||
expected: 42
|
||||
description: "Left operand is null, returns right operand"
|
||||
|
||||
- source: "undefined ?? 42"
|
||||
expected: 42
|
||||
description: "Left operand is undefined, returns right operand"
|
||||
|
||||
- source: "0 ?? 42"
|
||||
expected: 0
|
||||
description: "Left operand is 0 (falsy but not nullish), returns left operand"
|
||||
|
||||
- source: "'' ?? 'default'"
|
||||
expected: ""
|
||||
description: "Left operand is an empty string (falsy but not nullish), returns left operand"
|
||||
|
||||
- source: "false ?? true"
|
||||
expected: false
|
||||
description: "Left operand is false (falsy but not nullish), returns left operand"
|
||||
|
||||
- source: "42 ?? 0"
|
||||
expected: 42
|
||||
description: "Left operand is a non-nullish truthy value, returns left operand"
|
||||
|
||||
- source: "null ?? undefined"
|
||||
expected: __undefined__
|
||||
description: "Left operand is null, returns right operand which is undefined"
|
||||
|
||||
- source: "undefined ?? null"
|
||||
expected: __null__
|
||||
description: "Left operand is undefined, returns right operand which is null"
|
||||
|
||||
- source: "NaN ?? 42"
|
||||
expected: __NaN__
|
||||
description: "Left operand is NaN (not nullish), returns left operand"
|
||||
|
||||
- source: "[] ?? 'default'"
|
||||
expected: []
|
||||
description: "Left operand is an empty array (not nullish), returns left operand"
|
||||
|
||||
- source: "{} ?? 'default'"
|
||||
expected: {}
|
||||
description: "Left operand is an empty object (not nullish), returns left operand"
|
||||
|
||||
- source: "(null ?? 42) ?? 50"
|
||||
expected: 42
|
||||
description: "Nested nullish coalescing, first nullish operand replaced, second ignored"
|
||||
|
||||
- source: "(undefined ?? null) ?? 'fallback'"
|
||||
expected: fallback
|
||||
description: "Nested nullish coalescing"
|
||||
|
||||
- source: "(0 ?? null) ?? 'fallback'"
|
||||
expected: 0
|
||||
description: "Nested nullish coalescing with falsy but non-nullish value"
|
||||
|
||||
- source: "null ?? (undefined ?? 42)"
|
||||
expected: 42
|
||||
description: "Nullish coalescing in the right operand"
|
||||
|
||||
- source: "null ?? null ?? null ?? 'fallback'"
|
||||
expected: "fallback"
|
||||
description: "Chained nullish coalescing, resolves to the last non-nullish value"
|
||||
|
||||
- source: "null ?? (false ?? 'default')"
|
||||
expected: false
|
||||
description: "Right operand evaluates to non-nullish falsy value"
|
||||
|
||||
- source: "null ?? (true ?? 'default')"
|
||||
expected: true
|
||||
description: "Right operand evaluates to truthy value"
|
||||
|
||||
- source: "42 ?? (null ?? 0)"
|
||||
expected: 42
|
||||
description: "Left operand is not nullish, ignores right operand"
|
||||
|
||||
- source: "undefined ?? null ?? 'value'"
|
||||
expected: "value"
|
||||
description: "Chained nullish coalescing with undefined and null"
|
||||
|
||||
- source: "(NaN ?? null) ?? 42"
|
||||
expected: __NaN__
|
||||
description: "Left operand is NaN, not nullish, returns NaN"
|
||||
|
||||
- source: "(undefined ?? NaN) ?? 42"
|
||||
expected: __NaN__
|
||||
description: "Right operand resolves to NaN"
|
||||
|
||||
- source: "null ?? 'default' ?? 42"
|
||||
expected: "default"
|
||||
description: "Chained nullish coalescing, resolves to first non-nullish value"
|
||||
|
||||
- source: "'' ?? 'default' ?? 42"
|
||||
expected: ""
|
||||
description: "Falsy but non-nullish value, returns left operand"
|
||||
|
||||
- source: "null ?? undefined ?? NaN"
|
||||
expected: __NaN__
|
||||
description: "Chained nullish coalescing, resolves to NaN as the first non-nullish value"
|
||||
|
||||
- source: "(null ?? null) ?? undefined"
|
||||
expected: __undefined__
|
||||
description: "Nested nullish coalescing resolves to undefined"
|
||||
Reference in New Issue
Block a user