-
Notifications
You must be signed in to change notification settings - Fork 12.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11765 from Microsoft/aozgaa/AddTestForComparingNu…
…mericLiteral add test from comparing numeric literals to branded numbers
- Loading branch information
Showing
3 changed files
with
179 additions
and
0 deletions.
There are no files selected for viewing
58 changes: 58 additions & 0 deletions
58
tests/baselines/reference/comparisonOperatorWithNumericLiteral.errors.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 > <number>0; | ||
x > <BrandedNum>0; | ||
|
||
// operator < | ||
x < 0; | ||
~~~~~ | ||
!!! error TS2365: Operator '<' cannot be applied to types 'BrandedNum' and '0'. | ||
x < <number>0; | ||
x < <BrandedNum>0; | ||
|
||
// operator >= | ||
x >= 0; | ||
~~~~~~ | ||
!!! error TS2365: Operator '>=' cannot be applied to types 'BrandedNum' and '0'. | ||
x >= <number>0; | ||
x >= <BrandedNum>0; | ||
|
||
// operator <= | ||
x <= 0; | ||
~~~~~~ | ||
!!! error TS2365: Operator '<=' cannot be applied to types 'BrandedNum' and '0'. | ||
x <= <number>0; | ||
x <= <BrandedNum>0; | ||
|
||
// operator == | ||
x == 0; | ||
x == <number>0; | ||
x == <BrandedNum>0; | ||
|
||
// operator != | ||
x != 0; | ||
x != <number>0; | ||
x != <BrandedNum>0; | ||
|
||
// operator === | ||
x === 0; | ||
x === <number>0; | ||
x === <BrandedNum>0; | ||
|
||
// operator !== | ||
x !== 0; | ||
x !== <number>0; | ||
x !== <BrandedNum>0; | ||
|
79 changes: 79 additions & 0 deletions
79
tests/baselines/reference/comparisonOperatorWithNumericLiteral.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
//// [comparisonOperatorWithNumericLiteral.ts] | ||
type BrandedNum = number & { __numberBrand: any }; | ||
var x : BrandedNum; | ||
|
||
// operator > | ||
x > 0; | ||
x > <number>0; | ||
x > <BrandedNum>0; | ||
|
||
// operator < | ||
x < 0; | ||
x < <number>0; | ||
x < <BrandedNum>0; | ||
|
||
// operator >= | ||
x >= 0; | ||
x >= <number>0; | ||
x >= <BrandedNum>0; | ||
|
||
// operator <= | ||
x <= 0; | ||
x <= <number>0; | ||
x <= <BrandedNum>0; | ||
|
||
// operator == | ||
x == 0; | ||
x == <number>0; | ||
x == <BrandedNum>0; | ||
|
||
// operator != | ||
x != 0; | ||
x != <number>0; | ||
x != <BrandedNum>0; | ||
|
||
// operator === | ||
x === 0; | ||
x === <number>0; | ||
x === <BrandedNum>0; | ||
|
||
// operator !== | ||
x !== 0; | ||
x !== <number>0; | ||
x !== <BrandedNum>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; |
42 changes: 42 additions & 0 deletions
42
...ce/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNumericLiteral.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
type BrandedNum = number & { __numberBrand: any }; | ||
var x : BrandedNum; | ||
|
||
// operator > | ||
x > 0; | ||
x > <number>0; | ||
x > <BrandedNum>0; | ||
|
||
// operator < | ||
x < 0; | ||
x < <number>0; | ||
x < <BrandedNum>0; | ||
|
||
// operator >= | ||
x >= 0; | ||
x >= <number>0; | ||
x >= <BrandedNum>0; | ||
|
||
// operator <= | ||
x <= 0; | ||
x <= <number>0; | ||
x <= <BrandedNum>0; | ||
|
||
// operator == | ||
x == 0; | ||
x == <number>0; | ||
x == <BrandedNum>0; | ||
|
||
// operator != | ||
x != 0; | ||
x != <number>0; | ||
x != <BrandedNum>0; | ||
|
||
// operator === | ||
x === 0; | ||
x === <number>0; | ||
x === <BrandedNum>0; | ||
|
||
// operator !== | ||
x !== 0; | ||
x !== <number>0; | ||
x !== <BrandedNum>0; |