mirror of
https://github.com/dart-lang/sdk
synced 2024-11-02 09:43:08 +00:00
Migrate and clean up the prefix negative tests.
Since there were already non-negative tests with the same numbers, I gave them meaningful names. Merged a couple of tests into the same file when it made sense since multitests let us do that. Deleted prefix1_negative_test, because it essentially tested only that a random identifier does not resolve, which is not particularly related to prefixes. Change-Id: I91718f6df5126f123d9a8ea3abbc6898797db2db Reviewed-on: https://dart-review.googlesource.com/52985 Reviewed-by: Sigmund Cherem <sigmund@google.com>
This commit is contained in:
parent
1fcd896ed9
commit
bed71b7776
23 changed files with 114 additions and 257 deletions
|
@ -100,15 +100,7 @@ parameter_initializer3_negative_test: CompileTimeError
|
|||
parameter_initializer4_negative_test: CompileTimeError
|
||||
parameter_initializer6_negative_test: CompileTimeError
|
||||
part_refers_to_core_library_test/01: MissingCompileTimeError # Issue 29709
|
||||
prefix11_negative_test: Fail # Issue 11964
|
||||
prefix12_negative_test: Fail # Issue 11962
|
||||
prefix1_negative_test: Fail # Issue 11962
|
||||
prefix2_negative_test: Fail # Issue 11962
|
||||
prefix3_negative_test: Fail # Issue 12191
|
||||
prefix4_negative_test: Fail # Issue 11962
|
||||
prefix5_negative_test: Fail # Issue 11962
|
||||
prefix7_negative_test: CompileTimeError
|
||||
prefix8_negative_test: Fail # Issue 11964
|
||||
prefix_shadow_test/01: MissingCompileTimeError # Issue 33005
|
||||
private_member1_negative_test: Fail # Issue 14021
|
||||
private_member2_negative_test: Fail # Issue 14021
|
||||
private_member3_negative_test: Fail # Issue 14021
|
||||
|
@ -1161,10 +1153,6 @@ override_inheritance_method_test/28: CompileTimeError
|
|||
override_inheritance_method_test/29: CompileTimeError
|
||||
parameter_initializer_test: CompileTimeError
|
||||
parser_quirks_test: CompileTimeError
|
||||
prefix13_negative_test: CompileTimeError, OK
|
||||
prefix15_negative_test: CompileTimeError, OK
|
||||
prefix18_negative_test: CompileTimeError, OK
|
||||
prefix6_negative_test: CompileTimeError, OK
|
||||
regress_22976_test/01: CompileTimeError
|
||||
regress_22976_test/02: CompileTimeError
|
||||
regress_22976_test/none: CompileTimeError
|
||||
|
@ -1566,13 +1554,11 @@ partial_tearoff_instantiation_test/07: MissingCompileTimeError
|
|||
partial_tearoff_instantiation_test/08: MissingCompileTimeError
|
||||
positional_parameters_type_test/01: MissingCompileTimeError
|
||||
positional_parameters_type_test/02: MissingCompileTimeError
|
||||
prefix13_negative_test: CompileTimeError, OK
|
||||
prefix15_negative_test: CompileTimeError, OK
|
||||
prefix16_test/00: MissingCompileTimeError
|
||||
prefix16_test/01: MissingCompileTimeError
|
||||
prefix18_negative_test: CompileTimeError, OK
|
||||
prefix22_test/00: MissingCompileTimeError
|
||||
prefix23_test/00: MissingCompileTimeError
|
||||
prefix_shadow_test/02: MissingCompileTimeError
|
||||
private_access_test/01: MissingCompileTimeError
|
||||
private_access_test/02: MissingCompileTimeError
|
||||
private_access_test/03: MissingCompileTimeError
|
||||
|
|
|
@ -143,7 +143,7 @@ override_inheritance_method_test/28: CompileTimeError
|
|||
override_inheritance_method_test/29: CompileTimeError
|
||||
parameter_initializer_test: CompileTimeError
|
||||
part_refers_to_core_library_test/01: Crash
|
||||
prefix10_negative_test: Fail # Issue 29920
|
||||
prefix_shadow_test/01: MissingCompileTimeError # Issue 33005
|
||||
regress_23089_test: MissingCompileTimeError
|
||||
regress_23408_test: CompileTimeError
|
||||
regress_24283_test: RuntimeError # Intended to fail, requires 64-bit numbers.
|
||||
|
|
|
@ -1308,6 +1308,15 @@ override_inheritance_no_such_method_test/07: MissingCompileTimeError
|
|||
override_inheritance_no_such_method_test/09: MissingCompileTimeError
|
||||
override_inheritance_no_such_method_test/10: MissingCompileTimeError
|
||||
override_inheritance_no_such_method_test/12: MissingCompileTimeError
|
||||
prefix_import_collision_test/01: MissingCompileTimeError
|
||||
prefix_shadow_test/01: MissingCompileTimeError
|
||||
prefix_shadow_test/02: MissingCompileTimeError
|
||||
prefix_transitive_import_prefix_test/01: MissingCompileTimeError
|
||||
prefix_transitive_import_prefix_test/02: MissingCompileTimeError
|
||||
prefix_transitive_import_prefix_test/03: MissingCompileTimeError
|
||||
prefix_transitive_import_test/01: MissingCompileTimeError
|
||||
prefix_transitive_import_test/02: MissingCompileTimeError
|
||||
variable_shadow_class_test/01: MissingCompileTimeError
|
||||
|
||||
[ $fasta && $strong ]
|
||||
compile_time_constant_k_test/01: MissingCompileTimeError
|
||||
|
@ -1938,20 +1947,10 @@ partial_tearoff_instantiation_test/01: MissingCompileTimeError
|
|||
partial_tearoff_instantiation_test/03: MissingCompileTimeError
|
||||
positional_parameters_type_test/01: MissingCompileTimeError
|
||||
positional_parameters_type_test/02: MissingCompileTimeError
|
||||
prefix10_negative_test: Fail
|
||||
prefix11_negative_test: Fail
|
||||
prefix12_negative_test: Fail
|
||||
prefix16_test/00: MissingCompileTimeError
|
||||
prefix16_test/01: MissingCompileTimeError
|
||||
prefix1_negative_test: Fail
|
||||
prefix22_test/00: MissingCompileTimeError
|
||||
prefix23_test/00: MissingCompileTimeError
|
||||
prefix2_negative_test: Fail
|
||||
prefix3_negative_test: Fail
|
||||
prefix4_negative_test: Fail
|
||||
prefix5_negative_test: Fail
|
||||
prefix6_negative_test: Fail
|
||||
prefix8_negative_test: Fail
|
||||
private_access_test/01: MissingCompileTimeError
|
||||
private_access_test/02: MissingCompileTimeError
|
||||
private_access_test/03: MissingCompileTimeError
|
||||
|
|
|
@ -55,20 +55,6 @@ parameter_initializer2_negative_test: Skip # Negative, not syntax.
|
|||
parameter_initializer3_negative_test: Skip # Negative, not syntax.
|
||||
parameter_initializer4_negative_test: Skip # Negative, not syntax.
|
||||
parameter_initializer6_negative_test: Skip # Negative, not syntax.
|
||||
prefix10_negative_test: Skip # Negative, not syntax.
|
||||
prefix11_negative_test: Skip # Negative, not syntax.
|
||||
prefix12_negative_test: Skip # Negative, not syntax.
|
||||
prefix13_negative_test: Skip # Negative, not syntax.
|
||||
prefix15_negative_test: Skip # Negative, not syntax.
|
||||
prefix18_negative_test: Fail # Negative, uses `lib1.invalid` as library prefix.
|
||||
prefix1_negative_test: Skip # Negative, not syntax.
|
||||
prefix2_negative_test: Skip # Negative, not syntax.
|
||||
prefix3_negative_test: Skip # Negative, not syntax.
|
||||
prefix4_negative_test: Skip # Negative, not syntax.
|
||||
prefix5_negative_test: Skip # Negative, not syntax.
|
||||
prefix6_negative_test: Skip # Negative, not syntax.
|
||||
prefix7_negative_test: Skip # Negative, not syntax.
|
||||
prefix8_negative_test: Skip # Negative, not syntax.
|
||||
private_member1_negative_test: Skip # Negative, not syntax.
|
||||
private_member2_negative_test: Skip # Negative, not syntax.
|
||||
private_member3_negative_test: Skip # Negative, not syntax.
|
||||
|
|
|
@ -847,6 +847,14 @@ prefix16_test/00: MissingCompileTimeError
|
|||
prefix16_test/01: MissingCompileTimeError
|
||||
prefix22_test/00: MissingCompileTimeError
|
||||
prefix23_test/00: MissingCompileTimeError
|
||||
prefix_import_collision_test/01: MissingCompileTimeError
|
||||
prefix_shadow_test/01: MissingCompileTimeError
|
||||
prefix_shadow_test/02: MissingCompileTimeError
|
||||
prefix_transitive_import_prefix_test/01: MissingCompileTimeError
|
||||
prefix_transitive_import_prefix_test/02: MissingCompileTimeError
|
||||
prefix_transitive_import_prefix_test/03: MissingCompileTimeError
|
||||
prefix_transitive_import_test/01: MissingCompileTimeError
|
||||
prefix_transitive_import_test/02: MissingCompileTimeError
|
||||
private_access_test/01: MissingCompileTimeError
|
||||
private_access_test/02: MissingCompileTimeError
|
||||
private_access_test/03: MissingCompileTimeError
|
||||
|
@ -1031,6 +1039,7 @@ unresolved_default_constructor_test/01: MissingCompileTimeError
|
|||
unresolved_in_factory_test: MissingCompileTimeError
|
||||
unresolved_top_level_method_test: MissingCompileTimeError
|
||||
unresolved_top_level_var_test: MissingCompileTimeError
|
||||
variable_shadow_class_test/01: MissingCompileTimeError
|
||||
|
||||
[ $compiler != dartk && $runtime == vm && $checked ]
|
||||
call_method_as_cast_test/06: RuntimeError
|
||||
|
|
|
@ -1,9 +1,6 @@
|
|||
// 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.
|
||||
//
|
||||
|
||||
library library2.dart;
|
||||
|
||||
var foo;
|
||||
var foo1 = 0;
|
||||
|
|
|
@ -1,25 +0,0 @@
|
|||
// 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.
|
||||
//
|
||||
|
||||
// Type parameters can shadow a library prefix.
|
||||
|
||||
library Prefix10NegativeTest.dart;
|
||||
|
||||
import "package:expect/expect.dart";
|
||||
import "library10.dart" as T;
|
||||
|
||||
class P<T> {
|
||||
P.named(T this.fld);
|
||||
T fld;
|
||||
main() {
|
||||
var i = new T.Library10(10); // This should be an error.
|
||||
Expect.equals(10, i.fld);
|
||||
}
|
||||
}
|
||||
|
||||
main() {
|
||||
var i = new P<int>.named(10);
|
||||
i.main();
|
||||
}
|
|
@ -1,13 +0,0 @@
|
|||
// 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.
|
||||
//
|
||||
// Symbols in libraries imported by the prefixed library should not be visible
|
||||
|
||||
library Prefix12NegativeTest.dart;
|
||||
|
||||
import "library12.dart" as lib12;
|
||||
|
||||
main() {
|
||||
var obj = lib12.top_level11; // Error, variable should not be visible
|
||||
}
|
|
@ -1,18 +0,0 @@
|
|||
// 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.
|
||||
//
|
||||
// Unresolved symbols should be reported as an error.
|
||||
|
||||
library Prefix13NegativeTest.dart;
|
||||
|
||||
import "library12.dart" as lib12;
|
||||
|
||||
class myClass extends lib12.Library13 {
|
||||
myClass(int this.fld) : super(0);
|
||||
int fld;
|
||||
}
|
||||
|
||||
main() {
|
||||
new myClass(1);
|
||||
}
|
|
@ -1,19 +0,0 @@
|
|||
// 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.
|
||||
//
|
||||
|
||||
library Prefix1NegativeTest.dart;
|
||||
|
||||
import "library1.dart";
|
||||
|
||||
class Prefix1NegativeTest {
|
||||
static Main() {
|
||||
// This is a syntax error as library1 was not imported with a prefix.
|
||||
return library1.foo;
|
||||
}
|
||||
}
|
||||
|
||||
main() {
|
||||
Prefix1NegativeTest.Main();
|
||||
}
|
|
@ -1,19 +0,0 @@
|
|||
// 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.
|
||||
//
|
||||
|
||||
library Prefix2NegativeTest.dart;
|
||||
|
||||
import "library2.dart" as lib2;
|
||||
|
||||
class Prefix2NegativeTest {
|
||||
static Main() {
|
||||
// This is a syntax error as multiple prefixes are not possible.
|
||||
return lib2.Library2.main() + lib2.lib1.foo;
|
||||
}
|
||||
}
|
||||
|
||||
main() {
|
||||
Prefix2NegativeTest.Main();
|
||||
}
|
|
@ -1,25 +0,0 @@
|
|||
// 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.
|
||||
//
|
||||
|
||||
library Prefix4NegativeTest.dart;
|
||||
|
||||
import "package:expect/expect.dart";
|
||||
import "library10.dart";
|
||||
|
||||
class Prefix4NegativeTest {
|
||||
static Test1() {
|
||||
// Library prefixes in the imported libraries should not be visible here.
|
||||
var result = 0;
|
||||
var obj = new lib11.Library11(1);
|
||||
result = obj.fld;
|
||||
Expect.equals(1, result);
|
||||
result += obj.func();
|
||||
Expect.equals(3, result);
|
||||
}
|
||||
}
|
||||
|
||||
main() {
|
||||
Prefix4NegativeTest.Test1();
|
||||
}
|
|
@ -1,23 +0,0 @@
|
|||
// 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.
|
||||
|
||||
library Prefix5NegativeTest.dart;
|
||||
|
||||
import "package:expect/expect.dart";
|
||||
import "library10.dart";
|
||||
|
||||
class Prefix5NegativeTest {
|
||||
static Test1() {
|
||||
// Library prefixes in the imported libraries should not be visible here.
|
||||
var result = 0;
|
||||
result += lib11.Library11.static_func();
|
||||
Expect.equals(6, result);
|
||||
result += lib11.Library11.static_fld;
|
||||
Expect.equals(10, result);
|
||||
}
|
||||
}
|
||||
|
||||
main() {
|
||||
Prefix5NegativeTest.Test1();
|
||||
}
|
|
@ -1,21 +0,0 @@
|
|||
// 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.
|
||||
//
|
||||
|
||||
library Prefix6NegativeTest.dart;
|
||||
|
||||
import "library10.dart" as lib10;
|
||||
|
||||
class Prefix6NegativeTest {
|
||||
static Test1() {
|
||||
// Variables in the local scope hide the library prefix.
|
||||
var lib10 = 0;
|
||||
var result = 0;
|
||||
result += lib10.Library10.static_func(); // This should fail.
|
||||
}
|
||||
}
|
||||
|
||||
main() {
|
||||
Prefix6NegativeTest.Test1();
|
||||
}
|
|
@ -1,20 +0,0 @@
|
|||
// 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.
|
||||
//
|
||||
|
||||
import "package:expect/expect.dart";
|
||||
|
||||
// Local variables can shadow class names and hence should result in an
|
||||
// error.
|
||||
|
||||
class Test {
|
||||
Test.named(int this.fld);
|
||||
int fld;
|
||||
}
|
||||
|
||||
main() {
|
||||
var Test;
|
||||
var i = new Test.named(10); // This should be an error.
|
||||
Expect.equals(10, i.fld);
|
||||
}
|
|
@ -1,17 +1,13 @@
|
|||
// 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.
|
||||
//
|
||||
|
||||
// Using the same prefix name while importing two different libraries is
|
||||
// not an error but both library1.dart and library2.dart define 'foo' which
|
||||
// results in a duplicate definition error.
|
||||
|
||||
library Prefix3NegativeTest.dart;
|
||||
|
||||
import "library1.dart" as lib2; // defines 'foo'.
|
||||
import "library2.dart" as lib2; // also defines 'foo'.
|
||||
|
||||
main() {
|
||||
lib2.foo = 1;
|
||||
lib2.foo = 1; //# 01: compile-time error
|
||||
}
|
|
@ -1,11 +1,10 @@
|
|||
// 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.
|
||||
//
|
||||
// prefix must be a valid identifier
|
||||
|
||||
library Prefix18NegativeTest.dart;
|
||||
import "library1.dart" as lib1.invalid;
|
||||
// Prefix must be a valid identifier.
|
||||
import "library1.dart"
|
||||
as lib1.invalid //# 01: compile-time error
|
||||
;
|
||||
|
||||
main() {
|
||||
}
|
||||
main() {}
|
33
tests/language_2/prefix_shadow_test.dart
Normal file
33
tests/language_2/prefix_shadow_test.dart
Normal file
|
@ -0,0 +1,33 @@
|
|||
// 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.
|
||||
|
||||
// Type parameters can shadow a library prefix.
|
||||
|
||||
import "package:expect/expect.dart";
|
||||
import "library10.dart" as T;
|
||||
import "library10.dart" as lib10;
|
||||
|
||||
class P<T> {
|
||||
test() {
|
||||
new T.Library10(10); //# 01: compile-time error
|
||||
}
|
||||
}
|
||||
|
||||
main() {
|
||||
new P<int>().test();
|
||||
|
||||
{
|
||||
// Variables in the local scope hide the library prefix.
|
||||
var lib10 = 0; //# 02: compile-time error
|
||||
var result = 0;
|
||||
result = lib10.Library10.static_fld;
|
||||
Expect.equals(4, result);
|
||||
}
|
||||
|
||||
{
|
||||
// Shadowing is not an error.
|
||||
var lib10 = 1;
|
||||
Expect.equals(2, lib10 + 1);
|
||||
}
|
||||
}
|
11
tests/language_2/prefix_transitive_import_prefix_test.dart
Normal file
11
tests/language_2/prefix_transitive_import_prefix_test.dart
Normal file
|
@ -0,0 +1,11 @@
|
|||
// 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.
|
||||
import "library10.dart";
|
||||
|
||||
main() {
|
||||
// Library prefixes in the imported libraries should not be visible here.
|
||||
new lib11.Library11(1); //# 01: compile-time error
|
||||
lib11.Library11.static_func(); //# 02: compile-time error
|
||||
lib11.Library11.static_fld; //# 03: compile-time error
|
||||
}
|
|
@ -1,13 +1,15 @@
|
|||
// 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.
|
||||
//
|
||||
// Symbols in libraries imported by the prefixed library should not be visible
|
||||
|
||||
library Prefix11NegativeTest.dart;
|
||||
// Symbols in libraries imported by the prefixed library should not be visible.
|
||||
|
||||
import "library12.dart" as lib12;
|
||||
|
||||
main() {
|
||||
var obj = new lib12.Library11(1); // Error, method should not be visible
|
||||
// Class should not be visible.
|
||||
new lib12.Library11(1); //# 01: compile-time error
|
||||
|
||||
// Variable should not be visible.
|
||||
lib12.top_level11; //# 02: compile-time error
|
||||
}
|
|
@ -1,18 +1,19 @@
|
|||
// 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.
|
||||
//
|
||||
|
||||
// Unresolved symbols should be reported as an error.
|
||||
|
||||
library Prefix15NegativeTest.dart;
|
||||
|
||||
import "library12.dart" as lib12;
|
||||
|
||||
class myClass implements lib12.Library13 {
|
||||
myClass(int this.fld) : super(0);
|
||||
int fld;
|
||||
}
|
||||
class Subclass
|
||||
extends lib12.Library13 //# 01: compile-time error
|
||||
{}
|
||||
|
||||
class Implementer
|
||||
implements lib12.Library13 //# 02: compile-time error
|
||||
{}
|
||||
|
||||
main() {
|
||||
new myClass(1);
|
||||
new Subclass();
|
||||
new Implementer();
|
||||
}
|
|
@ -1,14 +1,9 @@
|
|||
// 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.
|
||||
//
|
||||
|
||||
library Prefix7NegativeTest.dart;
|
||||
|
||||
import "library10.dart" as lib10;
|
||||
|
||||
// Top level variables cannot shadow library prefixes, they should collide.
|
||||
|
||||
var lib10;
|
||||
var lib10; //# 01: compile-time error
|
||||
|
||||
main() {}
|
26
tests/language_2/variable_shadow_class_test.dart
Normal file
26
tests/language_2/variable_shadow_class_test.dart
Normal file
|
@ -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.
|
||||
import "package:expect/expect.dart";
|
||||
|
||||
// Local variables can shadow class names.
|
||||
|
||||
class Test {
|
||||
final int field;
|
||||
Test.named(this.field);
|
||||
}
|
||||
|
||||
main() {
|
||||
{
|
||||
var Test; //# 01: compile-time error
|
||||
// Now this refers to the variable.
|
||||
var i = new Test.named(10);
|
||||
Expect.equals(10, i.field);
|
||||
}
|
||||
|
||||
{
|
||||
// Shadowing is allowed.
|
||||
var Test = 1;
|
||||
Expect.equals(2, Test + 1);
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue