mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Add conformance test for ambient enum declaration
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
tests/cases/conformance/ambient/ambientEnumDeclaration1.ts(5,5): error TS1066: Ambient enum elements can only have integer literal initializers.
|
||||
tests/cases/conformance/ambient/ambientEnumDeclaration1.ts(6,5): error TS1066: Ambient enum elements can only have integer literal initializers.
|
||||
tests/cases/conformance/ambient/ambientEnumDeclaration1.ts(7,5): error TS1066: Ambient enum elements can only have integer literal initializers.
|
||||
tests/cases/conformance/ambient/ambientEnumDeclaration1.ts(8,5): error TS1066: Ambient enum elements can only have integer literal initializers.
|
||||
|
||||
|
||||
==== tests/cases/conformance/ambient/ambientEnumDeclaration1.ts (4 errors) ====
|
||||
// In ambient enum declarations, all values specified in enum member declarations must be classified as constant enum expressions.
|
||||
|
||||
declare enum E {
|
||||
a = 10,
|
||||
b = 10 + 1,
|
||||
~
|
||||
!!! error TS1066: Ambient enum elements can only have integer literal initializers.
|
||||
c = b,
|
||||
~
|
||||
!!! error TS1066: Ambient enum elements can only have integer literal initializers.
|
||||
d = (c) + 1,
|
||||
~
|
||||
!!! error TS1066: Ambient enum elements can only have integer literal initializers.
|
||||
e = 10 << 2 * 8,
|
||||
~
|
||||
!!! error TS1066: Ambient enum elements can only have integer literal initializers.
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
//// [ambientEnumDeclaration1.ts]
|
||||
// In ambient enum declarations, all values specified in enum member declarations must be classified as constant enum expressions.
|
||||
|
||||
declare enum E {
|
||||
a = 10,
|
||||
b = 10 + 1,
|
||||
c = b,
|
||||
d = (c) + 1,
|
||||
e = 10 << 2 * 8,
|
||||
}
|
||||
|
||||
//// [ambientEnumDeclaration1.js]
|
||||
// In ambient enum declarations, all values specified in enum member declarations must be classified as constant enum expressions.
|
||||
@@ -0,0 +1,17 @@
|
||||
//// [ambientEnumDeclaration2.ts]
|
||||
// In ambient enum declarations that specify no const modifier, enum member declarations
|
||||
// that omit a value are considered computed members (as opposed to having auto- incremented values assigned).
|
||||
|
||||
declare enum E {
|
||||
a, // E.a
|
||||
b, // E.b
|
||||
}
|
||||
|
||||
declare const enum E1 {
|
||||
a, // E.a = 0
|
||||
b, // E.b = 1
|
||||
}
|
||||
|
||||
//// [ambientEnumDeclaration2.js]
|
||||
// In ambient enum declarations that specify no const modifier, enum member declarations
|
||||
// that omit a value are considered computed members (as opposed to having auto- incremented values assigned).
|
||||
@@ -0,0 +1,23 @@
|
||||
=== tests/cases/conformance/ambient/ambientEnumDeclaration2.ts ===
|
||||
// In ambient enum declarations that specify no const modifier, enum member declarations
|
||||
// that omit a value are considered computed members (as opposed to having auto- incremented values assigned).
|
||||
|
||||
declare enum E {
|
||||
>E : E, Symbol(E, Decl(ambientEnumDeclaration2.ts, 0, 0))
|
||||
|
||||
a, // E.a
|
||||
>a : E, Symbol(E.a, Decl(ambientEnumDeclaration2.ts, 3, 16))
|
||||
|
||||
b, // E.b
|
||||
>b : E, Symbol(E.b, Decl(ambientEnumDeclaration2.ts, 4, 6))
|
||||
}
|
||||
|
||||
declare const enum E1 {
|
||||
>E1 : E1, Symbol(E1, Decl(ambientEnumDeclaration2.ts, 6, 1))
|
||||
|
||||
a, // E.a = 0
|
||||
>a : E1, Symbol(E1.a, Decl(ambientEnumDeclaration2.ts, 8, 23))
|
||||
|
||||
b, // E.b = 1
|
||||
>b : E1, Symbol(E1.b, Decl(ambientEnumDeclaration2.ts, 9, 6))
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
// In ambient enum declarations, all values specified in enum member declarations must be classified as constant enum expressions.
|
||||
|
||||
declare enum E {
|
||||
a = 10,
|
||||
b = 10 + 1,
|
||||
c = b,
|
||||
d = (c) + 1,
|
||||
e = 10 << 2 * 8,
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
// In ambient enum declarations that specify no const modifier, enum member declarations
|
||||
// that omit a value are considered computed members (as opposed to having auto- incremented values assigned).
|
||||
|
||||
declare enum E {
|
||||
a, // E.a
|
||||
b, // E.b
|
||||
}
|
||||
|
||||
declare const enum E1 {
|
||||
a, // E.a = 0
|
||||
b, // E.b = 1
|
||||
}
|
||||
Reference in New Issue
Block a user