-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…2240) Update variable tests according to the current spec. Part 2
- Loading branch information
Showing
35 changed files
with
951 additions
and
326 deletions.
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
Language/Statements/Local_Variable_Declaration/final_A01_t01.dart
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,23 @@ | ||
// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
|
||
/// @assertion If a local variable v is final and not late, it is not a | ||
/// compile-time error if the declaration of v is not an initializing variable | ||
/// declaration, but an expression that gives rise to evaluation of v is a | ||
/// compile-time error unless flow analysis shows that the variable is | ||
/// guaranteed to have been initialized. Similarly, an expression that gives | ||
/// rise to an assignment to v is a compile-time error unless flow analysis | ||
/// shows that it is guaranteed that the variable has not been initialized. | ||
/// | ||
/// In every situation which is not covered by the previous paragraph, it is a | ||
/// compile-time error to assign to a local variable which is final and not late | ||
/// | ||
/// @description Checks that it is not an error if a local variable is final and | ||
/// not initialized at its point of declaration. | ||
/// @author ilya | ||
main() { | ||
final i; | ||
i = 1; | ||
} |
26 changes: 26 additions & 0 deletions
26
Language/Statements/Local_Variable_Declaration/final_A01_t02.dart
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,26 @@ | ||
// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
|
||
/// @assertion If a local variable v is final and not late, it is not a | ||
/// compile-time error if the declaration of v is not an initializing variable | ||
/// declaration, but an expression that gives rise to evaluation of v is a | ||
/// compile-time error unless flow analysis shows that the variable is | ||
/// guaranteed to have been initialized. Similarly, an expression that gives | ||
/// rise to an assignment to v is a compile-time error unless flow analysis | ||
/// shows that it is guaranteed that the variable has not been initialized. | ||
/// | ||
/// In every situation which is not covered by the previous paragraph, it is a | ||
/// compile-time error to assign to a local variable which is final and not late | ||
/// | ||
/// @description Checks that it is not an error if a local variable is final and | ||
/// not initialized at its point of declaration. | ||
/// @author ilya | ||
main() { | ||
f() { | ||
final i; | ||
return i = 1; | ||
} | ||
f(); | ||
} |
25 changes: 25 additions & 0 deletions
25
Language/Statements/Local_Variable_Declaration/final_A01_t03.dart
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,25 @@ | ||
// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
|
||
/// @assertion If a local variable v is final and not late, it is not a | ||
/// compile-time error if the declaration of v is not an initializing variable | ||
/// declaration, but an expression that gives rise to evaluation of v is a | ||
/// compile-time error unless flow analysis shows that the variable is | ||
/// guaranteed to have been initialized. Similarly, an expression that gives | ||
/// rise to an assignment to v is a compile-time error unless flow analysis | ||
/// shows that it is guaranteed that the variable has not been initialized. | ||
/// | ||
/// In every situation which is not covered by the previous paragraph, it is a | ||
/// compile-time error to assign to a local variable which is final and not late | ||
/// | ||
/// @description Checks that it is not an error if a local variable is final | ||
/// and not initialized at its point of declaration. | ||
/// @author ilya | ||
main() { | ||
() { | ||
final i; | ||
return i = 1; | ||
} (); | ||
} |
29 changes: 29 additions & 0 deletions
29
Language/Statements/Local_Variable_Declaration/final_A01_t04.dart
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,29 @@ | ||
// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
|
||
/// @assertion If a local variable v is final and not late, it is not a | ||
/// compile-time error if the declaration of v is not an initializing variable | ||
/// declaration, but an expression that gives rise to evaluation of v is a | ||
/// compile-time error unless flow analysis shows that the variable is | ||
/// guaranteed to have been initialized. Similarly, an expression that gives | ||
/// rise to an assignment to v is a compile-time error unless flow analysis | ||
/// shows that it is guaranteed that the variable has not been initialized. | ||
/// | ||
/// In every situation which is not covered by the previous paragraph, it is a | ||
/// compile-time error to assign to a local variable which is final and not late | ||
/// | ||
/// @description Checks that it is not an error if a local variable is final and | ||
/// not initialized at its point of declaration. | ||
/// @author ilya | ||
class C { | ||
f() { | ||
final i; | ||
return i = 1; | ||
} | ||
} | ||
|
||
main() { | ||
new C().f(); | ||
} |
26 changes: 26 additions & 0 deletions
26
Language/Statements/Local_Variable_Declaration/final_A02_t01.dart
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,26 @@ | ||
// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
|
||
/// @assertion If a local variable v is final and not late, it is not a | ||
/// compile-time error if the declaration of v is not an initializing variable | ||
/// declaration, but an expression that gives rise to evaluation of v is a | ||
/// compile-time error unless flow analysis shows that the variable is | ||
/// guaranteed to have been initialized. Similarly, an expression that gives | ||
/// rise to an assignment to v is a compile-time error unless flow analysis | ||
/// shows that it is guaranteed that the variable has not been initialized. | ||
/// | ||
/// In every situation which is not covered by the previous paragraph, it is a | ||
/// compile-time error to assign to a local variable which is final and not late | ||
/// | ||
/// @description Checks that it is a compile-time error to read a local | ||
/// definitely unassigned final variable. | ||
/// @author ilya | ||
main() { | ||
final i; | ||
var j = i; | ||
// ^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
} |
29 changes: 29 additions & 0 deletions
29
Language/Statements/Local_Variable_Declaration/final_A02_t02.dart
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,29 @@ | ||
// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
|
||
/// @assertion If a local variable v is final and not late, it is not a | ||
/// compile-time error if the declaration of v is not an initializing variable | ||
/// declaration, but an expression that gives rise to evaluation of v is a | ||
/// compile-time error unless flow analysis shows that the variable is | ||
/// guaranteed to have been initialized. Similarly, an expression that gives | ||
/// rise to an assignment to v is a compile-time error unless flow analysis | ||
/// shows that it is guaranteed that the variable has not been initialized. | ||
/// | ||
/// In every situation which is not covered by the previous paragraph, it is a | ||
/// compile-time error to assign to a local variable which is final and not late | ||
/// | ||
/// @description Checks that it is a compile-time error to read a local | ||
/// definitely unassigned final variable. | ||
/// @author ilya | ||
main() { | ||
f() { | ||
final i; | ||
return i; | ||
// ^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
} | ||
f(); | ||
} |
28 changes: 28 additions & 0 deletions
28
Language/Statements/Local_Variable_Declaration/final_A02_t03.dart
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,28 @@ | ||
// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
|
||
/// @assertion If a local variable v is final and not late, it is not a | ||
/// compile-time error if the declaration of v is not an initializing variable | ||
/// declaration, but an expression that gives rise to evaluation of v is a | ||
/// compile-time error unless flow analysis shows that the variable is | ||
/// guaranteed to have been initialized. Similarly, an expression that gives | ||
/// rise to an assignment to v is a compile-time error unless flow analysis | ||
/// shows that it is guaranteed that the variable has not been initialized. | ||
/// | ||
/// In every situation which is not covered by the previous paragraph, it is a | ||
/// compile-time error to assign to a local variable which is final and not late | ||
/// | ||
/// @description Checks that it is a compile-time error to read a local | ||
/// definitely unassigned final variable. | ||
/// @author ilya | ||
main() { | ||
() { | ||
final i; | ||
return i; | ||
// ^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
} (); | ||
} |
33 changes: 33 additions & 0 deletions
33
Language/Statements/Local_Variable_Declaration/final_A02_t04.dart
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,33 @@ | ||
// Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
|
||
/// @assertion If a local variable v is final and not late, it is not a | ||
/// compile-time error if the declaration of v is not an initializing variable | ||
/// declaration, but an expression that gives rise to evaluation of v is a | ||
/// compile-time error unless flow analysis shows that the variable is | ||
/// guaranteed to have been initialized. Similarly, an expression that gives | ||
/// rise to an assignment to v is a compile-time error unless flow analysis | ||
/// shows that it is guaranteed that the variable has not been initialized. | ||
/// | ||
/// In every situation which is not covered by the previous paragraph, it is a | ||
/// compile-time error to assign to a local variable which is final and not late | ||
/// | ||
/// @description Checks that it is a compile-time error to read a local | ||
/// definitely unassigned final variable. | ||
/// @author [email protected] | ||
/// @author [email protected] | ||
class C { | ||
f() { | ||
final i; | ||
return i; | ||
// ^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
} | ||
} | ||
|
||
main() { | ||
new C().f(); | ||
} |
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
82 changes: 82 additions & 0 deletions
82
Language/Variables/Implicitly_Induced_Getters_and_Setters/definition_A01_t01.dart
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,82 @@ | ||
// Copyright (c) 2023, the Dart project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
|
||
/// @assertion Case ⟨Getter: Variable with declared type ⟩. Consider a variable | ||
/// declaration of one of the forms | ||
/// • static? late? final? T id; | ||
/// • static? late? final? T id = e; | ||
/// • static? const T id = e; | ||
/// where T is a type, id is an identifier, and ‘?’ indicates that the given | ||
/// modifier may be present or absent. Each of these declarations implicitly | ||
/// induces a getter with the header T get id. | ||
/// ... | ||
/// In these cases the declared type of id is T. | ||
/// | ||
/// @description Checks that the static type of an implicit getter is its | ||
/// declared type | ||
/// @author [email protected] | ||
import "../../../Utils/static_type_helper.dart"; | ||
|
||
late final int? x1; | ||
late int x2; | ||
int? x3; | ||
late final int x4 = 4; | ||
late int x5 = 5; | ||
final int x6 = 6; | ||
int x7 = 7; | ||
const int x8 = 8; | ||
|
||
class C { | ||
static late final int v11; | ||
static late int v12; | ||
late int v13; | ||
int? v14; | ||
late final int v15; | ||
late int v16; | ||
|
||
static late final int v21 = 21; | ||
static late int v22 = 22; | ||
static int v23 = 23; | ||
static final int v24 = 24; | ||
late final int v25 = 25; | ||
late int v26 = 26; | ||
final int v27 = 27; | ||
int v28 = 28; | ||
|
||
static const int v31 = 31; | ||
} | ||
|
||
main() { | ||
x1 = 1 as dynamic; | ||
x1.expectStaticType<Exactly<int?>>(); | ||
x2.expectStaticType<Exactly<int>>(); | ||
x3.expectStaticType<Exactly<int?>>(); | ||
x4.expectStaticType<Exactly<int>>(); | ||
x5.expectStaticType<Exactly<int>>(); | ||
x6.expectStaticType<Exactly<int>>(); | ||
|
||
C c = C(); | ||
C.v11 = 11 as dynamic; | ||
C.v12 = 12 as dynamic; | ||
c.v13 = 13 as dynamic; | ||
c.v14 = 14 as dynamic; | ||
c.v15 = 15 as dynamic; | ||
c.v16 = 16 as dynamic; | ||
C.v11.expectStaticType<Exactly<int>>(); | ||
C.v12.expectStaticType<Exactly<int>>(); | ||
c.v13.expectStaticType<Exactly<int>>(); | ||
c.v14.expectStaticType<Exactly<int?>>(); | ||
c.v15.expectStaticType<Exactly<int>>(); | ||
c.v16.expectStaticType<Exactly<int>>(); | ||
C.v21.expectStaticType<Exactly<int>>(); | ||
C.v22.expectStaticType<Exactly<int>>(); | ||
C.v23.expectStaticType<Exactly<int>>(); | ||
C.v24.expectStaticType<Exactly<int>>(); | ||
c.v25.expectStaticType<Exactly<int>>(); | ||
c.v26.expectStaticType<Exactly<int>>(); | ||
c.v27.expectStaticType<Exactly<int>>(); | ||
c.v28.expectStaticType<Exactly<int>>(); | ||
C.v31.expectStaticType<Exactly<int>>(); | ||
} |
Oops, something went wrong.