forked from dart-lang/co19
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
dart-lang#1401. If- and for-elements tests for maps and sets added
- Loading branch information
Showing
43 changed files
with
2,278 additions
and
8 deletions.
There are no files selected for viewing
31 changes: 31 additions & 0 deletions
31
LanguageFeatures/Patterns/execution_pattern_for_element_A01_t06.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,31 @@ | ||
// 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 | ||
/// Likewise, a collection element of the form: | ||
/// | ||
/// for (<patternVariableDeclaration>; <condition>; <increment>) <element> | ||
/// Is executed like a traditional for loop though is more likely to declare | ||
/// multiple variables | ||
/// | ||
/// @description Check that a pattern-for element is executed like a traditional | ||
/// for loop. Test variable and identifier subpatterns of a parenthesized | ||
/// pattern. Test pattern-for element in a map literal | ||
/// @author [email protected] | ||
// SharedOptions=--enable-experiment=patterns | ||
|
||
import "../../Utils/expect.dart"; | ||
|
||
main() { | ||
var map1 = { | ||
"k0": 0, | ||
for (var (int i) = 1; i <= 3; (i) = (i + 1)) "k$i": i, | ||
"k4": 4 | ||
}; | ||
Expect.mapEquals({"k0": 0, "k1": 1, "k2": 2, "k3": 3, "k4": 4}, map1); | ||
int j = -1; | ||
var map2 = {"k0": 0, for ((j) = 1; j < 4; (j) = (j + 1)) "k$j": j, "k4": 4}; | ||
Expect.mapEquals({"k0": 0, "k1": 1, "k2": 2, "k3": 3, "k4": 4}, map2); | ||
} |
36 changes: 36 additions & 0 deletions
36
LanguageFeatures/Patterns/execution_pattern_for_element_A01_t07.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,36 @@ | ||
// 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 | ||
/// Likewise, a collection element of the form: | ||
/// | ||
/// for (<patternVariableDeclaration>; <condition>; <increment>) <element> | ||
/// Is executed like a traditional for loop though is more likely to declare | ||
/// multiple variables | ||
/// | ||
/// @description Check that a pattern-for element is executed like a traditional | ||
/// for loop. Test a list pattern in a map literal | ||
/// @author [email protected] | ||
// SharedOptions=--enable-experiment=patterns | ||
|
||
import "../../Utils/expect.dart"; | ||
|
||
main() { | ||
var map = { | ||
"k-1": -1, | ||
for (var [a, b] = [0, 1]; a <= 8; [a, b] = [b, a + b]) "k$a": a, | ||
"k13": 13 | ||
}; | ||
Expect.mapEquals({ | ||
"k-1": -1, | ||
"k0": 0, | ||
"k1": 1, | ||
"k2": 2, | ||
"k3": 3, | ||
"k5": 5, | ||
"k8": 8, | ||
"k13": 13 | ||
}, map); | ||
} |
39 changes: 39 additions & 0 deletions
39
LanguageFeatures/Patterns/execution_pattern_for_element_A01_t08.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,39 @@ | ||
// 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 | ||
/// Likewise, a collection element of the form: | ||
/// | ||
/// for (<patternVariableDeclaration>; <condition>; <increment>) <element> | ||
/// Is executed like a traditional for loop though is more likely to declare | ||
/// multiple variables | ||
/// | ||
/// @description Check that a pattern-for element is executed like a traditional | ||
/// for loop. Test a map pattern in a map literal | ||
/// @author [email protected] | ||
// SharedOptions=--enable-experiment=patterns | ||
|
||
import "../../Utils/expect.dart"; | ||
|
||
main() { | ||
var map = { | ||
"k-1": -1, | ||
for (var {"k1": a, "k2": b} = {"k1": 0, "k2": 1}; | ||
a <= 8; | ||
{"k1": a, "k2": b} = {"k1": b, "k2": a + b}) | ||
"k$a": a, | ||
"k13": 13 | ||
}; | ||
Expect.mapEquals({ | ||
"k-1": -1, | ||
"k0": 0, | ||
"k1": 1, | ||
"k2": 2, | ||
"k3": 3, | ||
"k5": 5, | ||
"k8": 8, | ||
"k13": 13 | ||
}, map); | ||
} |
36 changes: 36 additions & 0 deletions
36
LanguageFeatures/Patterns/execution_pattern_for_element_A01_t09.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,36 @@ | ||
// 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 | ||
/// Likewise, a collection element of the form: | ||
/// | ||
/// for (<patternVariableDeclaration>; <condition>; <increment>) <element> | ||
/// Is executed like a traditional for loop though is more likely to declare | ||
/// multiple variables | ||
/// | ||
/// @description Check that a pattern-for element is executed like a traditional | ||
/// for loop. Test a record pattern in a map literal | ||
/// @author [email protected] | ||
// SharedOptions=--enable-experiment=patterns,records | ||
|
||
import "../../Utils/expect.dart"; | ||
|
||
main() { | ||
var map = { | ||
"k-1": -1, | ||
for (var (a, b) = (0, 1); a <= 8; (a, b) = (b, a + b)) "k$a": a, | ||
"k13": 13 | ||
}; | ||
Expect.mapEquals({ | ||
"k-1": -1, | ||
"k0": 0, | ||
"k1": 1, | ||
"k2": 2, | ||
"k3": 3, | ||
"k5": 5, | ||
"k8": 8, | ||
"k13": 13 | ||
}, map); | ||
} |
31 changes: 31 additions & 0 deletions
31
LanguageFeatures/Patterns/execution_pattern_for_element_A01_t10.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,31 @@ | ||
// 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 | ||
/// Likewise, a collection element of the form: | ||
/// | ||
/// for (<patternVariableDeclaration>; <condition>; <increment>) <element> | ||
/// Is executed like a traditional for loop though is more likely to declare | ||
/// multiple variables | ||
/// | ||
/// @description Check that a pattern-for element is executed like a traditional | ||
/// for loop. Test an object pattern in a map literal | ||
/// @author [email protected] | ||
// SharedOptions=--enable-experiment=patterns,records | ||
|
||
import "../../Utils/expect.dart"; | ||
import "patterns_lib.dart"; | ||
|
||
main() { | ||
var map = { | ||
"k0": 0, | ||
for (var Square(:areaAsInt) = Square(1); | ||
areaAsInt <= 9; | ||
Square(:areaAsInt) = Square((++areaAsInt).toDouble())) | ||
"k$areaAsInt": areaAsInt, | ||
"k42": 42 | ||
}; | ||
Expect.mapEquals({"k0": 0, "k1": 1, "k4": 4, "k42": 42}, map); | ||
} |
27 changes: 27 additions & 0 deletions
27
LanguageFeatures/Patterns/execution_pattern_for_element_A01_t11.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,27 @@ | ||
// 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 | ||
/// Likewise, a collection element of the form: | ||
/// | ||
/// for (<patternVariableDeclaration>; <condition>; <increment>) <element> | ||
/// Is executed like a traditional for loop though is more likely to declare | ||
/// multiple variables | ||
/// | ||
/// @description Check that a pattern-for element is executed like a traditional | ||
/// for loop. Test variable and identifier subpatterns of a parenthesized | ||
/// pattern. Test pattern-for element in a set literal | ||
/// @author [email protected] | ||
// SharedOptions=--enable-experiment=patterns | ||
|
||
import "../../Utils/expect.dart"; | ||
|
||
main() { | ||
var set1 = {0, for (var (int i) = 1; i <= 3; (i) = (i + 1)) i, 4}; | ||
Expect.setEquals({0, 1, 2, 3, 4}, set1); | ||
int j = -1; | ||
var set2 = {0, for ((j) = 1; j < 4; (j) = (j + 1)) j, 4}; | ||
Expect.setEquals({0, 1, 2, 3, 4}, set2); | ||
} |
27 changes: 27 additions & 0 deletions
27
LanguageFeatures/Patterns/execution_pattern_for_element_A01_t12.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,27 @@ | ||
// 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 | ||
/// Likewise, a collection element of the form: | ||
/// | ||
/// for (<patternVariableDeclaration>; <condition>; <increment>) <element> | ||
/// Is executed like a traditional for loop though is more likely to declare | ||
/// multiple variables | ||
/// | ||
/// @description Check that a pattern-for element is executed like a traditional | ||
/// for loop. Test a list pattern in a set literal | ||
/// @author [email protected] | ||
// SharedOptions=--enable-experiment=patterns | ||
|
||
import "../../Utils/expect.dart"; | ||
|
||
main() { | ||
var set = { | ||
-1, | ||
for (var [a, b] = [0, 1]; a <= 8; [a, b] = [b, a + b]) a, | ||
13 | ||
}; | ||
Expect.setEquals({-1, 0, 1, 2, 3, 5, 8, 13}, set); | ||
} |
30 changes: 30 additions & 0 deletions
30
LanguageFeatures/Patterns/execution_pattern_for_element_A01_t13.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,30 @@ | ||
// 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 | ||
/// Likewise, a collection element of the form: | ||
/// | ||
/// for (<patternVariableDeclaration>; <condition>; <increment>) <element> | ||
/// Is executed like a traditional for loop though is more likely to declare | ||
/// multiple variables | ||
/// | ||
/// @description Check that a pattern-for element is executed like a traditional | ||
/// for loop. Test a map pattern in a set literal | ||
/// @author [email protected] | ||
// SharedOptions=--enable-experiment=patterns | ||
|
||
import "../../Utils/expect.dart"; | ||
|
||
main() { | ||
var set = { | ||
-1, | ||
for (var {"k1": a, "k2": b} = {"k1": 0, "k2": 1}; | ||
a <= 8; | ||
{"k1": a, "k2": b} = {"k1": b, "k2": a + b}) | ||
a, | ||
13 | ||
}; | ||
Expect.setEquals({-1, 0, 1, 2, 3, 5, 8, 13}, set); | ||
} |
23 changes: 23 additions & 0 deletions
23
LanguageFeatures/Patterns/execution_pattern_for_element_A01_t14.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) 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 | ||
/// Likewise, a collection element of the form: | ||
/// | ||
/// for (<patternVariableDeclaration>; <condition>; <increment>) <element> | ||
/// Is executed like a traditional for loop though is more likely to declare | ||
/// multiple variables | ||
/// | ||
/// @description Check that a pattern-for element is executed like a traditional | ||
/// for loop. Test a record pattern in a set literal | ||
/// @author [email protected] | ||
// SharedOptions=--enable-experiment=patterns,records | ||
|
||
import "../../Utils/expect.dart"; | ||
|
||
main() { | ||
var set = {-1, for (var (a, b) = (0, 1); a <= 8; (a, b) = (b, a + b)) a, 13}; | ||
Expect.setEquals({-1, 0, 1, 2, 3, 5, 8, 13}, set); | ||
} |
31 changes: 31 additions & 0 deletions
31
LanguageFeatures/Patterns/execution_pattern_for_element_A01_t15.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,31 @@ | ||
// 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 | ||
/// Likewise, a collection element of the form: | ||
/// | ||
/// for (<patternVariableDeclaration>; <condition>; <increment>) <element> | ||
/// Is executed like a traditional for loop though is more likely to declare | ||
/// multiple variables | ||
/// | ||
/// @description Check that a pattern-for element is executed like a traditional | ||
/// for loop. Test an object pattern in a set literal | ||
/// @author [email protected] | ||
// SharedOptions=--enable-experiment=patterns,records | ||
|
||
import "../../Utils/expect.dart"; | ||
import "patterns_lib.dart"; | ||
|
||
main() { | ||
var set = { | ||
0, | ||
for (var Square(:areaAsInt) = Square(1); | ||
areaAsInt <= 9; | ||
Square(:areaAsInt) = Square((++areaAsInt).toDouble())) | ||
areaAsInt, | ||
42 | ||
}; | ||
Expect.setEquals({0, 1, 4, 42}, set); | ||
} |
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 |
---|---|---|
|
@@ -12,7 +12,7 @@ | |
/// | ||
/// @description Check that a pattern-for element is executed like a traditional | ||
/// for loop. Test that it is a compile-time error if a final variable is | ||
/// assigned in a pattern-for element | ||
/// assigned in a pattern-for element in a list literal | ||
/// @author [email protected] | ||
// SharedOptions=--enable-experiment=patterns,records | ||
|
54 changes: 54 additions & 0 deletions
54
LanguageFeatures/Patterns/execution_pattern_for_element_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,54 @@ | ||
// 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 | ||
/// A statement of the form: | ||
/// | ||
/// for (<patternVariableDeclaration>; <condition>; <increment>) <statement> | ||
/// | ||
/// Is executed like a traditional for loop though is more likely to declare | ||
/// multiple variables. | ||
/// | ||
/// @description Check that a pattern-for element is executed like a traditional | ||
/// for loop. Test that it is a compile-time error if a final variable is | ||
/// assigned in a pattern-for element in a map literal | ||
/// @author [email protected] | ||
// SharedOptions=--enable-experiment=patterns,records | ||
|
||
import "patterns_lib.dart"; | ||
|
||
main() { | ||
var m1 = { | ||
for (final (int i) = 0; i < 3; i++) "k$i": i, | ||
// ^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
}; | ||
var m2 = { | ||
for (final [a] = [0]; a < 3; [a] = [a + 1]) "k$a": a, | ||
// ^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
}; | ||
var m3 = { | ||
for (final {"k1": a} = {"k1": 0}; a < 3; {"k1": a} = {"k1": a + 1}) "k$a": a, | ||
// ^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
}; | ||
var m4 = { | ||
for (final (a,) = (0,); a < 3; (a,) = (a + 1,)) "k$a": a, | ||
// ^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
}; | ||
var m5 = { | ||
for (final Square(:areaAsInt) = Square(1); areaAsInt < 2; | ||
Square(:areaAsInt) = Square(areaAsInt + 1)) "k$areaAsInt": areaAsInt, | ||
// ^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
}; | ||
} |
Oops, something went wrong.