From 81383e172f715ec005d0110d4bbf672685f92644 Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Thu, 20 Oct 2016 15:56:21 -0700 Subject: [PATCH 1/2] add test --- .../comparisonOperatorWithNumericLiteral.ts | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNumericLiteral.ts diff --git a/tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNumericLiteral.ts b/tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNumericLiteral.ts new file mode 100644 index 0000000000000..457a324e97111 --- /dev/null +++ b/tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNumericLiteral.ts @@ -0,0 +1,42 @@ +type BrandedNum = number & { __numberBrand: any }; +var x : BrandedNum; + +// operator > +x > 0; +x > 0; +x > 0; + +// operator < +x < 0; +x < 0; +x < 0; + +// operator >= +x >= 0; +x >= 0; +x >= 0; + +// operator <= +x <= 0; +x <= 0; +x <= 0; + +// operator == +x == 0; +x == 0; +x == 0; + +// operator != +x != 0; +x != 0; +x != 0; + +// operator === +x === 0; +x === 0; +x === 0; + +// operator !== +x !== 0; +x !== 0; +x !== 0; From 1a41ebf542525847b5f041b0db5b544dc0d93697 Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Thu, 20 Oct 2016 16:27:02 -0700 Subject: [PATCH 2/2] update baselines --- ...risonOperatorWithNumericLiteral.errors.txt | 58 ++++++++++++++ .../comparisonOperatorWithNumericLiteral.js | 79 +++++++++++++++++++ .../comparisonOperatorWithNumericLiteral.ts | 42 ++++++++++ 3 files changed, 179 insertions(+) create mode 100644 tests/baselines/reference/comparisonOperatorWithNumericLiteral.errors.txt create mode 100644 tests/baselines/reference/comparisonOperatorWithNumericLiteral.js create mode 100644 tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNumericLiteral.ts diff --git a/tests/baselines/reference/comparisonOperatorWithNumericLiteral.errors.txt b/tests/baselines/reference/comparisonOperatorWithNumericLiteral.errors.txt new file mode 100644 index 0000000000000..d863ca29090b8 --- /dev/null +++ b/tests/baselines/reference/comparisonOperatorWithNumericLiteral.errors.txt @@ -0,0 +1,58 @@ +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNumericLiteral.ts(5,1): error TS2365: Operator '>' cannot be applied to types 'BrandedNum' and '0'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNumericLiteral.ts(10,1): error TS2365: Operator '<' cannot be applied to types 'BrandedNum' and '0'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNumericLiteral.ts(15,1): error TS2365: Operator '>=' cannot be applied to types 'BrandedNum' and '0'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNumericLiteral.ts(20,1): error TS2365: Operator '<=' cannot be applied to types 'BrandedNum' and '0'. + + +==== tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNumericLiteral.ts (4 errors) ==== + type BrandedNum = number & { __numberBrand: any }; + var x : BrandedNum; + + // operator > + x > 0; + ~~~~~ +!!! error TS2365: Operator '>' cannot be applied to types 'BrandedNum' and '0'. + x > 0; + x > 0; + + // operator < + x < 0; + ~~~~~ +!!! error TS2365: Operator '<' cannot be applied to types 'BrandedNum' and '0'. + x < 0; + x < 0; + + // operator >= + x >= 0; + ~~~~~~ +!!! error TS2365: Operator '>=' cannot be applied to types 'BrandedNum' and '0'. + x >= 0; + x >= 0; + + // operator <= + x <= 0; + ~~~~~~ +!!! error TS2365: Operator '<=' cannot be applied to types 'BrandedNum' and '0'. + x <= 0; + x <= 0; + + // operator == + x == 0; + x == 0; + x == 0; + + // operator != + x != 0; + x != 0; + x != 0; + + // operator === + x === 0; + x === 0; + x === 0; + + // operator !== + x !== 0; + x !== 0; + x !== 0; + \ No newline at end of file diff --git a/tests/baselines/reference/comparisonOperatorWithNumericLiteral.js b/tests/baselines/reference/comparisonOperatorWithNumericLiteral.js new file mode 100644 index 0000000000000..6f28423d16616 --- /dev/null +++ b/tests/baselines/reference/comparisonOperatorWithNumericLiteral.js @@ -0,0 +1,79 @@ +//// [comparisonOperatorWithNumericLiteral.ts] +type BrandedNum = number & { __numberBrand: any }; +var x : BrandedNum; + +// operator > +x > 0; +x > 0; +x > 0; + +// operator < +x < 0; +x < 0; +x < 0; + +// operator >= +x >= 0; +x >= 0; +x >= 0; + +// operator <= +x <= 0; +x <= 0; +x <= 0; + +// operator == +x == 0; +x == 0; +x == 0; + +// operator != +x != 0; +x != 0; +x != 0; + +// operator === +x === 0; +x === 0; +x === 0; + +// operator !== +x !== 0; +x !== 0; +x !== 0; + + +//// [comparisonOperatorWithNumericLiteral.js] +var x; +// operator > +x > 0; +x > 0; +x > 0; +// operator < +x < 0; +x < 0; +x < 0; +// operator >= +x >= 0; +x >= 0; +x >= 0; +// operator <= +x <= 0; +x <= 0; +x <= 0; +// operator == +x == 0; +x == 0; +x == 0; +// operator != +x != 0; +x != 0; +x != 0; +// operator === +x === 0; +x === 0; +x === 0; +// operator !== +x !== 0; +x !== 0; +x !== 0; diff --git a/tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNumericLiteral.ts b/tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNumericLiteral.ts new file mode 100644 index 0000000000000..457a324e97111 --- /dev/null +++ b/tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNumericLiteral.ts @@ -0,0 +1,42 @@ +type BrandedNum = number & { __numberBrand: any }; +var x : BrandedNum; + +// operator > +x > 0; +x > 0; +x > 0; + +// operator < +x < 0; +x < 0; +x < 0; + +// operator >= +x >= 0; +x >= 0; +x >= 0; + +// operator <= +x <= 0; +x <= 0; +x <= 0; + +// operator == +x == 0; +x == 0; +x == 0; + +// operator != +x != 0; +x != 0; +x != 0; + +// operator === +x === 0; +x === 0; +x === 0; + +// operator !== +x !== 0; +x !== 0; +x !== 0;