[cfe] Support experimental flags and language versions in message_suite.dart
Change-Id: I150a93834783219c73f9dc4961eb83a48a7ea7e1 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/194067 Commit-Queue: Johnni Winther <johnniwinther@google.com> Reviewed-by: Jens Johansen <jensj@google.com>
This commit is contained in:
committed by
commit-bot@chromium.org
parent
d27f166b75
commit
5f57456528
@@ -427,7 +427,7 @@ class _SyncClosureContext implements ClosureContext {
|
||||
returnType = _declaredReturnType;
|
||||
}
|
||||
if (inferrer.library.isNonNullableByDefault &&
|
||||
(containsInvalidType(returnType) ||
|
||||
(!containsInvalidType(returnType) &&
|
||||
returnType.isPotentiallyNonNullable) &&
|
||||
inferrer.flowAnalysis.isReachable) {
|
||||
Statement resultStatement =
|
||||
@@ -830,7 +830,7 @@ class _AsyncClosureContext implements ClosureContext {
|
||||
}
|
||||
returnType = inferrer.typeSchemaEnvironment.flatten(returnType);
|
||||
if (inferrer.library.isNonNullableByDefault &&
|
||||
(containsInvalidType(returnType) ||
|
||||
(!containsInvalidType(returnType) &&
|
||||
returnType.isPotentiallyNonNullable) &&
|
||||
inferrer.flowAnalysis.isReachable) {
|
||||
Statement resultStatement =
|
||||
|
||||
@@ -744,13 +744,8 @@ SuperclassMethodArgumentMismatch/analyzerCode: Fail
|
||||
SuperclassMethodArgumentMismatch/example: Fail
|
||||
SupertypeIsFunction/analyzerCode: Fail
|
||||
SupertypeIsFunction/example: Fail
|
||||
SupertypeIsIllegal/example: Fail
|
||||
SupertypeIsIllegalAliased/example: Fail
|
||||
SupertypeIsNullableAliased/example: Fail
|
||||
SupertypeIsTypeVariable/example: Fail
|
||||
SwitchCaseFallThrough/example: Fail
|
||||
SwitchExpressionNotSubtype/analyzerCode: Fail
|
||||
SwitchExpressionNotSubtype/example: Fail
|
||||
SwitchExpressionUserDefinedEquals/analyzerCode: Fail
|
||||
SwitchExpressionUserDefinedEquals/example: Fail
|
||||
SyntheticToken/example: Fail # Can't be tested, used to recover from other errors.
|
||||
@@ -786,7 +781,6 @@ UndefinedExtensionOperator/analyzerCode: Fail
|
||||
UndefinedExtensionOperator/example: Fail
|
||||
UndefinedExtensionSetter/analyzerCode: Fail
|
||||
UndefinedExtensionSetter/example: Fail
|
||||
UnexpectedModifierInNonNnbd/part_wrapped_script: Fail # Test requires @dart= annotation
|
||||
UnexpectedToken/part_wrapped_script1: Fail
|
||||
UnexpectedToken/script1: Fail
|
||||
UnmatchedToken/part_wrapped_script1: Fail
|
||||
|
||||
+118
-50
@@ -14,6 +14,9 @@
|
||||
# should be the path to an external test. The external test will not be run,
|
||||
# but the existence of the file will be verified.
|
||||
#
|
||||
# Multiple scripts can start with a `// @dart=` annotation to enforce the
|
||||
# language version used for the example code.
|
||||
#
|
||||
# Note that it can be hard or impossible to write an example that only gives the
|
||||
# specific error. To allow for this, one can specify
|
||||
# "exampleAllowMoreCodes: true" which filters out every message with a
|
||||
@@ -588,12 +591,20 @@ AbstractClassMember:
|
||||
tip: "Try removing the 'abstract' keyword. You can add the 'abstract' keyword before the class declaration."
|
||||
analyzerCode: ParserErrorCode.ABSTRACT_CLASS_MEMBER
|
||||
script:
|
||||
- "abstract class C {abstract C.c();}"
|
||||
- "abstract class C {abstract m();}"
|
||||
- "abstract class C {abstract get m;}"
|
||||
- "abstract class C {abstract set m(int x);}"
|
||||
- "abstract class C {abstract var f;}"
|
||||
- "abstract class C {abstract static var f;}"
|
||||
- |
|
||||
abstract class C {abstract C.c();}
|
||||
- |
|
||||
abstract class C {abstract m();}
|
||||
- |
|
||||
abstract class C {abstract get m;}
|
||||
- |
|
||||
abstract class C {abstract set m(int x);}
|
||||
- |
|
||||
// @dart=2.9
|
||||
abstract class C {abstract var f;}
|
||||
- |
|
||||
// @dart=2.9
|
||||
abstract class C {abstract static var f;}
|
||||
|
||||
AbstractExternalField:
|
||||
index: 110
|
||||
@@ -720,8 +731,11 @@ ConstFactory:
|
||||
template: "Only redirecting factory constructors can be declared to be 'const'."
|
||||
tip: "Try removing the 'const' keyword, or replacing the body with '=' followed by a valid target."
|
||||
analyzerCode: ParserErrorCode.CONST_FACTORY
|
||||
script:
|
||||
- "class C { const factory C() {} }"
|
||||
script: |
|
||||
class C {
|
||||
const factory C() => const C.internal();
|
||||
const C.internal();
|
||||
}
|
||||
|
||||
ConstFactoryRedirectionToNonConst:
|
||||
template: "Constant factory constructor can't delegate to a non-constant constructor."
|
||||
@@ -762,8 +776,11 @@ TypeBeforeFactory:
|
||||
template: "Factory constructors cannot have a return type."
|
||||
tip: "Try removing the type appearing before 'factory'."
|
||||
analyzerCode: ParserErrorCode.TYPE_BEFORE_FACTORY
|
||||
script:
|
||||
- "class C { T factory C() { return null; } }"
|
||||
script: |
|
||||
class C {
|
||||
T factory C() { return new C.constructor(); }
|
||||
C.constructor();
|
||||
}
|
||||
|
||||
ConstConstructorWithBody:
|
||||
template: "A const constructor can't have a body."
|
||||
@@ -828,7 +845,9 @@ ExternalField:
|
||||
tip: "Try removing the keyword 'external', or replacing the field by an external getter and/or setter."
|
||||
analyzerCode: ParserErrorCode.EXTERNAL_FIELD
|
||||
script:
|
||||
- "class C { external var f; }"
|
||||
- |
|
||||
// @dart=2.9
|
||||
class C { external var f; }
|
||||
|
||||
|
||||
ExternalFieldInitializer:
|
||||
@@ -885,10 +904,10 @@ RedirectingConstructorWithAnotherInitializer:
|
||||
# also ASSERT_IN_REDIRECTING_CONSTRUCTOR
|
||||
analyzerCode: FIELD_INITIALIZER_REDIRECTING_CONSTRUCTOR
|
||||
script:
|
||||
- "class C { int x; C(); C.bad() : x = 5, this(); }"
|
||||
- "class C { int x; C(); C.bad() : this(), x = 5; }"
|
||||
- "class C { int x; C(); C.bad() : assert(true), this(); }"
|
||||
- "class C { int x; C(); C.bad() : this(), assert(true); }"
|
||||
- "class C { int? x; C(); C.bad() : x = 5, this(); }"
|
||||
- "class C { int? x; C(); C.bad() : this(), x = 5; }"
|
||||
- "class C { int? x; C(); C.bad() : assert(true), this(); }"
|
||||
- "class C { int? x; C(); C.bad() : this(), assert(true); }"
|
||||
|
||||
SuperInitializerNotLast:
|
||||
template: "Can't have initializers after 'super'."
|
||||
@@ -1575,10 +1594,20 @@ ConstructorWithTypeParameters:
|
||||
analyzerCode: ParserErrorCode.TYPE_PARAMETER_ON_CONSTRUCTOR
|
||||
tip: "Try removing the type parameters."
|
||||
script:
|
||||
- "class C { C<T>() {} }"
|
||||
- "class C { C.foo<T>() {} }"
|
||||
- "class C { factory C<T>() => null; }"
|
||||
- "class C { factory C.foo<T>() => null; }"
|
||||
- >-
|
||||
class C { C<T>() {} }
|
||||
- >-
|
||||
class C { C.foo<T>() {} }
|
||||
- >-
|
||||
class C {
|
||||
factory C<T>() => new C.internal();
|
||||
C.internal();
|
||||
}
|
||||
- >-
|
||||
class C {
|
||||
factory C.foo<T>() => new C.internal();
|
||||
C.internal();
|
||||
}
|
||||
|
||||
ConstructorWithTypeArguments:
|
||||
template: "A constructor invocation can't have type arguments on the constructor name."
|
||||
@@ -1593,9 +1622,18 @@ ConstructorWithWrongName:
|
||||
analyzerCode: ParserErrorCode.INVALID_CONSTRUCTOR_NAME
|
||||
index: 102
|
||||
script:
|
||||
- "class A { B.foo() {} }"
|
||||
- "class A { factory B() => null; }"
|
||||
- "class A { factory B.foo() => null; }"
|
||||
- >-
|
||||
class A { B.foo() {} }
|
||||
- >-
|
||||
class A {
|
||||
factory B() => new A.internal();
|
||||
A.internal();
|
||||
}
|
||||
- >-
|
||||
class A {
|
||||
factory B.foo() => new A.internal();
|
||||
A.internal();
|
||||
}
|
||||
|
||||
ConstructorWithWrongNameContext:
|
||||
template: "The name of the enclosing class is '#name'."
|
||||
@@ -2379,6 +2417,7 @@ InvalidGetterSetterTypeBothInheritedGetter:
|
||||
InvalidGetterSetterTypeLegacy:
|
||||
template: "The type '#type' of the getter '#name' is not assignable to the type '#type2' of the setter '#name2'."
|
||||
script: |
|
||||
// @dart=2.9
|
||||
abstract class A {
|
||||
String get property;
|
||||
void set property(int i);
|
||||
@@ -2387,6 +2426,7 @@ InvalidGetterSetterTypeLegacy:
|
||||
InvalidGetterSetterTypeGetterInheritedLegacy:
|
||||
template: "The type '#type' of the inherited getter '#name' is not assignable to the type '#type2' of the setter '#name2'."
|
||||
script: |
|
||||
// @dart=2.9
|
||||
abstract class A {
|
||||
String get property;
|
||||
}
|
||||
@@ -2397,6 +2437,7 @@ InvalidGetterSetterTypeGetterInheritedLegacy:
|
||||
InvalidGetterSetterTypeFieldInheritedLegacy:
|
||||
template: "The type '#type' of the inherited field '#name' is not assignable to the type '#type2' of the setter '#name2'."
|
||||
script: |
|
||||
// @dart=2.9
|
||||
abstract class A {
|
||||
final String property;
|
||||
A(this.property);
|
||||
@@ -2408,6 +2449,7 @@ InvalidGetterSetterTypeFieldInheritedLegacy:
|
||||
InvalidGetterSetterTypeSetterInheritedGetterLegacy:
|
||||
template: "The type '#type' of the getter '#name' is not assignable to the type '#type2' of the inherited setter '#name2'."
|
||||
script: |
|
||||
// @dart=2.9
|
||||
abstract class A {
|
||||
void set property(int i);
|
||||
}
|
||||
@@ -2418,6 +2460,7 @@ InvalidGetterSetterTypeSetterInheritedGetterLegacy:
|
||||
InvalidGetterSetterTypeSetterInheritedFieldLegacy:
|
||||
template: "The type '#type' of the field '#name' is not assignable to the type '#type2' of the inherited setter '#name2'."
|
||||
script: |
|
||||
// @dart=2.9
|
||||
abstract class A {
|
||||
void set property(int i);
|
||||
}
|
||||
@@ -2429,6 +2472,7 @@ InvalidGetterSetterTypeSetterInheritedFieldLegacy:
|
||||
InvalidGetterSetterTypeBothInheritedFieldLegacy:
|
||||
template: "The type '#type' of the inherited field '#name' is not assignable to the type '#type2' of the inherited setter '#name2'."
|
||||
script: |
|
||||
// @dart=2.9
|
||||
abstract class A {
|
||||
final String property;
|
||||
A(this.property);
|
||||
@@ -2441,6 +2485,7 @@ InvalidGetterSetterTypeBothInheritedFieldLegacy:
|
||||
InvalidGetterSetterTypeBothInheritedGetterLegacy:
|
||||
template: "The type '#type' of the inherited getter '#name' is not assignable to the type '#type2' of the inherited setter '#name2'."
|
||||
script: |
|
||||
// @dart=2.9
|
||||
abstract class A {
|
||||
String get property;
|
||||
}
|
||||
@@ -2535,8 +2580,8 @@ ExternalConstructorWithInitializer:
|
||||
template: "An external constructor can't have any initializers."
|
||||
analyzerCode: ParserErrorCode.EXTERNAL_CONSTRUCTOR_WITH_INITIALIZER
|
||||
script:
|
||||
- "class C { int x; external C() : x = 1; }"
|
||||
- "class C { int x; external C.foo() : x = 1; }"
|
||||
- "class C { int? x; external C() : x = 1; }"
|
||||
- "class C { int? x; external C.foo() : x = 1; }"
|
||||
|
||||
ExternalTypedef:
|
||||
index: 76
|
||||
@@ -2578,7 +2623,9 @@ TypedefTypeVariableNotConstructorCause:
|
||||
TypedefNullableType:
|
||||
template: "Can't create typedef from nullable type."
|
||||
configuration: nnbd-strong
|
||||
script: typedef F = void Function()?;
|
||||
script: |
|
||||
// @dart=2.12
|
||||
typedef F = void Function()?;
|
||||
|
||||
TypedefUnaliasedTypeCause:
|
||||
template: "This is the type denoted by the type alias."
|
||||
@@ -2898,8 +2945,8 @@ MemberWithSameNameAsClass:
|
||||
- "class C { get C => 42; }"
|
||||
- "class C { set C(x) {} }"
|
||||
- "class C { set C(x) => 42; }"
|
||||
- "class C { int C; }"
|
||||
- "class C { int A, B, C, D, E; }"
|
||||
- "class C { int? C; }"
|
||||
- "class C { int? A, B, C, D, E; }"
|
||||
|
||||
EnumConstantSameNameAsEnclosing:
|
||||
template: "Name of enum constant '#name' can't be the same as the enum's own name."
|
||||
@@ -2951,18 +2998,30 @@ OperatorMinusParameterMismatch:
|
||||
SupertypeIsIllegal:
|
||||
template: "The type '#name' can't be used as supertype."
|
||||
analyzerCode: EXTENDS_NON_CLASS
|
||||
script: |
|
||||
class C extends dynamic {}
|
||||
|
||||
SupertypeIsIllegalAliased:
|
||||
template: "The type '#name' which is an alias of '#type' can't be used as supertype."
|
||||
analyzerCode: EXTENDS_NON_CLASS
|
||||
script: |
|
||||
typedef F = void Function();
|
||||
class C extends F {}
|
||||
|
||||
SupertypeIsNullableAliased:
|
||||
template: "The type '#name' which is an alias of '#type' can't be used as supertype because it is nullable."
|
||||
analyzerCode: EXTENDS_NON_CLASS
|
||||
experiments: nonfunction-type-aliases
|
||||
script: |
|
||||
class A {}
|
||||
typedef B = A?;
|
||||
class C extends B {}
|
||||
|
||||
SupertypeIsTypeVariable:
|
||||
template: "The type variable '#name' can't be used as supertype."
|
||||
analyzerCode: EXTENDS_NON_CLASS
|
||||
script: |
|
||||
class C<T> extends T {}
|
||||
|
||||
PartOfLibraryNameMismatch:
|
||||
template: "Using '#uri' as part of '#name' but its 'part of' declaration says '#name2'."
|
||||
@@ -3033,7 +3092,8 @@ SwitchExpressionNotAssignable:
|
||||
template: "Type '#type' of the switch expression isn't assignable to the type '#type2' of this case expression."
|
||||
analyzerCode: SWITCH_EXPRESSION_NOT_ASSIGNABLE
|
||||
script:
|
||||
- >-
|
||||
- |
|
||||
// @dart=2.9
|
||||
void f() {
|
||||
switch (42) {
|
||||
case "foo": break;
|
||||
@@ -3046,6 +3106,13 @@ SwitchExpressionNotAssignableCause:
|
||||
|
||||
SwitchExpressionNotSubtype:
|
||||
template: "Type '#type' of the case expression is not a subtype of type '#type2' of this switch expression."
|
||||
script:
|
||||
- |
|
||||
void f() {
|
||||
switch (42) {
|
||||
case "foo": break;
|
||||
}
|
||||
}
|
||||
|
||||
SwitchHasCaseAfterDefault:
|
||||
index: 16
|
||||
@@ -3107,14 +3174,14 @@ TypeVariableInStaticContext:
|
||||
- |
|
||||
class C<T> {
|
||||
static staticMethod() {
|
||||
List<T> t = null;
|
||||
List<T>? t = null;
|
||||
return t;
|
||||
}
|
||||
}
|
||||
- |
|
||||
class C<T> {
|
||||
static staticMethod() {
|
||||
T t = null;
|
||||
T? t = null;
|
||||
return t;
|
||||
}
|
||||
}
|
||||
@@ -3132,13 +3199,13 @@ TypeVariableInConstantContext:
|
||||
- |
|
||||
class C<T> {
|
||||
instanceMethod() {
|
||||
return const <T>[null];
|
||||
return const <T>[];
|
||||
}
|
||||
}
|
||||
- |
|
||||
class C<T> {
|
||||
instanceMethod() {
|
||||
return const <List<T>>[null];
|
||||
return const <List<T>>[];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3509,8 +3576,7 @@ UndefinedGetter:
|
||||
analyzerCode: UNDEFINED_GETTER
|
||||
script: >
|
||||
class C {}
|
||||
main() {
|
||||
C c;
|
||||
test(C c) {
|
||||
print(c.foo);
|
||||
}
|
||||
|
||||
@@ -3520,8 +3586,7 @@ UndefinedSetter:
|
||||
analyzerCode: UNDEFINED_SETTER
|
||||
script: >
|
||||
class C {}
|
||||
main() {
|
||||
C c;
|
||||
test(C c) {
|
||||
c.foo = 0;
|
||||
}
|
||||
|
||||
@@ -3531,8 +3596,7 @@ UndefinedMethod:
|
||||
analyzerCode: UNDEFINED_METHOD
|
||||
script: >
|
||||
class C {}
|
||||
main() {
|
||||
C c;
|
||||
test(C c) {
|
||||
c.foo();
|
||||
}
|
||||
|
||||
@@ -3542,8 +3606,7 @@ UndefinedOperator:
|
||||
analyzerCode: UNDEFINED_METHOD
|
||||
script: >
|
||||
class C {}
|
||||
main() {
|
||||
C c;
|
||||
test(C c) {
|
||||
c + 0;
|
||||
}
|
||||
|
||||
@@ -3947,7 +4010,9 @@ ReturnWithoutExpression:
|
||||
template: "Must explicitly return a value from a non-void function."
|
||||
severity: WARNING
|
||||
analyzerCode: RETURN_WITHOUT_VALUE
|
||||
declaration: "int foo() { return; }"
|
||||
script: |
|
||||
// @dart=2.9
|
||||
int foo() { return; }
|
||||
|
||||
ReturnWithoutExpressionSync:
|
||||
template: "A value must be explicitly returned from a non-void function."
|
||||
@@ -4025,6 +4090,7 @@ InvokeNonFunction:
|
||||
template: "'#name' isn't a function or method and can't be invoked."
|
||||
analyzerCode: INVOCATION_OF_NON_FUNCTION
|
||||
script: |
|
||||
// @dart=2.9
|
||||
class Foo {
|
||||
int f;
|
||||
}
|
||||
@@ -4100,8 +4166,8 @@ IncompatibleRedirecteeFunctionType:
|
||||
}
|
||||
- >-
|
||||
class A {
|
||||
factory A.f({int x}) = A.g;
|
||||
A.g({int y}) { }
|
||||
factory A.f({int? x}) = A.g;
|
||||
A.g({int? y}) { }
|
||||
}
|
||||
- >-
|
||||
class A {
|
||||
@@ -4159,7 +4225,7 @@ IncorrectTypeArgumentInReturnType:
|
||||
analyzerCode: TYPE_ARGUMENT_NOT_MATCHING_BOUNDS
|
||||
script: >
|
||||
class A<T extends num> {}
|
||||
A<String> foo() => null;
|
||||
A<String> foo() => throw '';
|
||||
|
||||
IncorrectTypeArgumentInferred:
|
||||
template: "Inferred type argument '#type' doesn't conform to the bound '#type2' of the type variable '#name' on '#name2'."
|
||||
@@ -4217,14 +4283,16 @@ GenericFunctionTypeUsedAsActualTypeArgument:
|
||||
analyzerCode: GENERIC_FUNCTION_CANNOT_BE_TYPE_ARGUMENT
|
||||
script:
|
||||
- >-
|
||||
typedef F = List<T> Function<T>(T);
|
||||
typedef F = Class<T> Function<T>(T);
|
||||
class Class<T> {}
|
||||
main() {
|
||||
List<F> list1;
|
||||
Class<F> class1;
|
||||
}
|
||||
- >-
|
||||
typedef F = List<T> Function<T>(T);
|
||||
typedef F = Class<T> Function<T>(T);
|
||||
class Class<T> {}
|
||||
main() {
|
||||
new List<F>();
|
||||
Class<F>();
|
||||
}
|
||||
|
||||
GenericFunctionTypeInferredAsActualTypeArgument:
|
||||
@@ -4400,7 +4468,7 @@ SpreadTypeMismatch:
|
||||
}
|
||||
- |
|
||||
main() {
|
||||
int Function() a = null;
|
||||
int Function() a = () => 42;
|
||||
var b = [...a];
|
||||
}
|
||||
|
||||
@@ -4443,7 +4511,7 @@ SpreadMapEntryTypeMismatch:
|
||||
}
|
||||
- |
|
||||
main() {
|
||||
int Function() a = null;
|
||||
int Function() a = () => 42;
|
||||
var b = <dynamic, dynamic>{...a};
|
||||
}
|
||||
|
||||
|
||||
@@ -28,10 +28,14 @@ import "package:vm/target/vm.dart" show VmTarget;
|
||||
import "package:yaml/yaml.dart" show YamlList, YamlMap, YamlNode, loadYamlNode;
|
||||
|
||||
import 'package:front_end/src/api_prototype/compiler_options.dart'
|
||||
show CompilerOptions, InvocationMode;
|
||||
show
|
||||
CompilerOptions,
|
||||
InvocationMode,
|
||||
parseExperimentalArguments,
|
||||
parseExperimentalFlags;
|
||||
|
||||
import 'package:front_end/src/api_prototype/experimental_flags.dart'
|
||||
show ExperimentalFlag;
|
||||
show ExperimentalFlag, defaultExperimentalFlags;
|
||||
|
||||
import 'package:front_end/src/api_prototype/memory_file_system.dart'
|
||||
show MemoryFileSystem;
|
||||
@@ -78,10 +82,7 @@ class Configuration {
|
||||
|
||||
CompilerOptions apply(CompilerOptions options) {
|
||||
if (nnbdMode != null) {
|
||||
options.explicitExperimentalFlags[ExperimentalFlag.nonNullable] = true;
|
||||
options.nnbdMode = nnbdMode;
|
||||
} else {
|
||||
options.explicitExperimentalFlags[ExperimentalFlag.nonNullable] = false;
|
||||
}
|
||||
options.invocationModes = invocationModes;
|
||||
return options;
|
||||
@@ -169,6 +170,7 @@ class MessageTestSuite extends ChainContext {
|
||||
"'spell_checking_list_messages.txt' or "
|
||||
"'spell_checking_list_common.txt'.";
|
||||
Configuration configuration;
|
||||
Map<ExperimentalFlag, bool> experimentalFlags;
|
||||
|
||||
Source source;
|
||||
List<String> formatSpellingMistakes(spell.SpellingResult spellResult,
|
||||
@@ -372,6 +374,16 @@ class MessageTestSuite extends ChainContext {
|
||||
}
|
||||
break;
|
||||
|
||||
case "experiments":
|
||||
if (value is String) {
|
||||
experimentalFlags = parseExperimentalFlags(
|
||||
parseExperimentalArguments(value.split(',')),
|
||||
onError: (message) => throw new ArgumentError(message));
|
||||
} else {
|
||||
throw new ArgumentError("Unknown experiments value: $value.");
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
unknownKeys.add(key);
|
||||
}
|
||||
@@ -386,6 +398,8 @@ class MessageTestSuite extends ChainContext {
|
||||
for (Example example in examples) {
|
||||
example.configuration =
|
||||
configuration ?? Configuration.defaultConfiguration;
|
||||
example.experimentalFlags =
|
||||
experimentalFlags ?? defaultExperimentalFlags;
|
||||
}
|
||||
|
||||
MessageTestDescription createDescription(
|
||||
@@ -527,15 +541,13 @@ abstract class Example {
|
||||
|
||||
Configuration configuration;
|
||||
|
||||
Map<ExperimentalFlag, bool> experimentalFlags;
|
||||
|
||||
Example(this.name, this.expectedCode);
|
||||
|
||||
YamlNode get node;
|
||||
|
||||
Uint8List get bytes;
|
||||
|
||||
Map<String, Uint8List> get scripts {
|
||||
return {mainFilename: bytes};
|
||||
}
|
||||
Map<String, Script> get scripts;
|
||||
|
||||
String get mainFilename => "main.dart";
|
||||
}
|
||||
@@ -544,12 +556,16 @@ class BytesExample extends Example {
|
||||
@override
|
||||
final YamlList node;
|
||||
|
||||
@override
|
||||
final Uint8List bytes;
|
||||
|
||||
BytesExample(String name, String code, this.node)
|
||||
: bytes = new Uint8List.fromList(node.cast<int>()),
|
||||
super(name, code);
|
||||
|
||||
@override
|
||||
Map<String, Script> get scripts {
|
||||
return {mainFilename: new Script(bytes, '', null)};
|
||||
}
|
||||
}
|
||||
|
||||
class DeclarationExample extends Example {
|
||||
@@ -563,13 +579,15 @@ class DeclarationExample extends Example {
|
||||
super(name, code);
|
||||
|
||||
@override
|
||||
Uint8List get bytes {
|
||||
return new Uint8List.fromList(utf8.encode("""
|
||||
Map<String, Script> get scripts {
|
||||
return {
|
||||
mainFilename: new Script.fromSource("""
|
||||
$declaration
|
||||
|
||||
main() {
|
||||
}
|
||||
"""));
|
||||
""")
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -584,12 +602,14 @@ class StatementExample extends Example {
|
||||
super(name, code);
|
||||
|
||||
@override
|
||||
Uint8List get bytes {
|
||||
return new Uint8List.fromList(utf8.encode("""
|
||||
Map<String, Script> get scripts {
|
||||
return {
|
||||
mainFilename: new Script.fromSource("""
|
||||
main() {
|
||||
$statement
|
||||
}
|
||||
"""));
|
||||
""")
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -603,13 +623,14 @@ class ExpressionExample extends Example {
|
||||
: expression = node.value,
|
||||
super(name, code);
|
||||
|
||||
@override
|
||||
Uint8List get bytes {
|
||||
return new Uint8List.fromList(utf8.encode("""
|
||||
Map<String, Script> get scripts {
|
||||
return {
|
||||
mainFilename: new Script.fromSource("""
|
||||
main() {
|
||||
$expression;
|
||||
}
|
||||
"""));
|
||||
""")
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -630,20 +651,17 @@ class ScriptExample extends Example {
|
||||
}
|
||||
|
||||
@override
|
||||
Uint8List get bytes => throw "Unsupported: ScriptExample.bytes";
|
||||
|
||||
@override
|
||||
Map<String, Uint8List> get scripts {
|
||||
Map<String, Script> get scripts {
|
||||
Object script = this.script;
|
||||
if (script is Map) {
|
||||
var scriptFiles = <String, Uint8List>{};
|
||||
Map<String, Script> scriptFiles = <String, Script>{};
|
||||
script.forEach((fileName, value) {
|
||||
scriptFiles[fileName] = new Uint8List.fromList(utf8.encode(value));
|
||||
scriptFiles[fileName] = new Script.fromSource(value);
|
||||
print("$fileName => $value\n\n======\n\n");
|
||||
});
|
||||
return scriptFiles;
|
||||
} else {
|
||||
return {mainFilename: new Uint8List.fromList(utf8.encode(script))};
|
||||
return {mainFilename: new Script.fromSource(script)};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -656,19 +674,17 @@ class PartWrapExample extends Example {
|
||||
PartWrapExample(String name, String code, this.allowMoreCodes, this.example)
|
||||
: super(name, code) {
|
||||
configuration = example.configuration;
|
||||
experimentalFlags = example.experimentalFlags;
|
||||
}
|
||||
|
||||
@override
|
||||
Uint8List get bytes => throw "Unsupported: PartWrapExample.bytes";
|
||||
|
||||
@override
|
||||
String get mainFilename => "main_wrapped.dart";
|
||||
|
||||
@override
|
||||
Map<String, Uint8List> get scripts {
|
||||
Map<String, Uint8List> wrapped = example.scripts;
|
||||
Map<String, Script> get scripts {
|
||||
Map<String, Script> wrapped = example.scripts;
|
||||
|
||||
var scriptFiles = <String, Uint8List>{};
|
||||
Map<String, Script> scriptFiles = <String, Script>{};
|
||||
scriptFiles.addAll(wrapped);
|
||||
|
||||
// Create a new main file
|
||||
@@ -677,21 +693,35 @@ class PartWrapExample extends Example {
|
||||
throw "Framework failure: "
|
||||
"Wanted to create wrapper file, but the file already exists!";
|
||||
}
|
||||
scriptFiles[mainFilename] = new Uint8List.fromList(utf8.encode("""
|
||||
part "${example.mainFilename}";
|
||||
"""));
|
||||
Script originalMainScript = scriptFiles[example.mainFilename];
|
||||
String preamble = originalMainScript.preamble;
|
||||
scriptFiles[mainFilename] = new Script.fromSource("""
|
||||
${preamble}part "${example.mainFilename}";
|
||||
""");
|
||||
|
||||
// Modify the original main file to be part of the wrapper and add lots of
|
||||
// gunk so every actual position in the file is not a valid position in the
|
||||
// wrapper.
|
||||
scriptFiles[example.mainFilename] = new Uint8List.fromList(utf8.encode("""
|
||||
part of "${mainFilename}";
|
||||
// La la la la la la la la la la la la la.
|
||||
// La la la la la la la la la la la la la.
|
||||
// La la la la la la la la la la la la la.
|
||||
// La la la la la la la la la la la la la.
|
||||
// La la la la la la la la la la la la la.
|
||||
""") + scriptFiles[example.mainFilename]);
|
||||
String originalMainSource = originalMainScript.sourceWithoutPreamble;
|
||||
String partPrefix = """
|
||||
${preamble}part of "${mainFilename}";
|
||||
// La la la la la la la la la la la la la.
|
||||
// La la la la la la la la la la la la la.
|
||||
// La la la la la la la la la la la la la.
|
||||
// La la la la la la la la la la la la la.
|
||||
// La la la la la la la la la la la la la.
|
||||
|
||||
""";
|
||||
if (originalMainSource != null) {
|
||||
scriptFiles[example.mainFilename] =
|
||||
new Script.fromSource('$partPrefix$originalMainSource');
|
||||
} else {
|
||||
scriptFiles[example.mainFilename] = new Script(
|
||||
new Uint8List.fromList(
|
||||
utf8.encode(partPrefix) + originalMainScript.bytes),
|
||||
'',
|
||||
null);
|
||||
}
|
||||
|
||||
return scriptFiles;
|
||||
}
|
||||
@@ -723,9 +753,9 @@ class Compile extends Step<Example, Null, MessageTestSuite> {
|
||||
Future<Result<Null>> run(Example example, MessageTestSuite suite) async {
|
||||
if (example == null) return pass(null);
|
||||
String dir = "${example.expectedCode}/${example.name}";
|
||||
example.scripts.forEach((String fileName, Uint8List bytes) {
|
||||
example.scripts.forEach((String fileName, Script script) {
|
||||
Uri uri = suite.fileSystem.currentDirectory.resolve("$dir/$fileName");
|
||||
suite.fileSystem.entityForUri(uri).writeAsBytesSync(bytes);
|
||||
suite.fileSystem.entityForUri(uri).writeAsBytesSync(script.bytes);
|
||||
});
|
||||
Uri main = suite.fileSystem.currentDirectory
|
||||
.resolve("$dir/${example.mainFilename}");
|
||||
@@ -749,6 +779,7 @@ class Compile extends Step<Example, Null, MessageTestSuite> {
|
||||
example.configuration.apply(new CompilerOptions()
|
||||
..sdkSummary = computePlatformBinariesLocation(forceBuildDir: true)
|
||||
.resolve("vm_platform_strong.dill")
|
||||
..explicitExperimentalFlags = example.experimentalFlags ?? {}
|
||||
..target = new VmTarget(new TargetFlags())
|
||||
..fileSystem = new HybridFileSystem(suite.fileSystem)
|
||||
..packagesFileUri = dotPackagesUri
|
||||
@@ -814,5 +845,29 @@ String relativize(Uri uri) {
|
||||
}
|
||||
}
|
||||
|
||||
class Script {
|
||||
final Uint8List bytes;
|
||||
final String preamble;
|
||||
final String sourceWithoutPreamble;
|
||||
|
||||
Script(this.bytes, this.preamble, this.sourceWithoutPreamble);
|
||||
|
||||
factory Script.fromSource(String source) {
|
||||
List<String> lines = source.split('\n');
|
||||
String firstLine = lines.first;
|
||||
String preamble;
|
||||
String sourceWithoutPreamble;
|
||||
if (firstLine.trim().startsWith('//') && firstLine.contains('@dart=')) {
|
||||
preamble = '$firstLine\n';
|
||||
sourceWithoutPreamble = lines.skip(1).join('\n');
|
||||
} else {
|
||||
preamble = '';
|
||||
sourceWithoutPreamble = source;
|
||||
}
|
||||
return new Script(new Uint8List.fromList(utf8.encode(source)), preamble,
|
||||
sourceWithoutPreamble);
|
||||
}
|
||||
}
|
||||
|
||||
main([List<String> arguments = const []]) =>
|
||||
runMe(arguments, createContext, configurationPath: "../../testing.json");
|
||||
|
||||
@@ -38,10 +38,6 @@ library /*isNonNullableByDefault*/;
|
||||
// Constraints get constraints {}
|
||||
// ^^^^^^^^^^^
|
||||
//
|
||||
// pkg/front_end/testcases/general/crashes/crash_01/main_lib.dart:2:19: Error: A non-null value must be returned since the return type 'invalid-type' doesn't allow null.
|
||||
// Constraints get constraints {}
|
||||
// ^
|
||||
//
|
||||
import self as mai;
|
||||
import "dart:core" as core;
|
||||
|
||||
@@ -49,11 +45,7 @@ abstract class RenderObject extends core::Object {
|
||||
synthetic constructor •() → mai::RenderObject
|
||||
: super core::Object::•()
|
||||
;
|
||||
get constraints() → invalid-type {
|
||||
return let final Never #t1 = invalid-expression "pkg/front_end/testcases/general/crashes/crash_01/main_lib.dart:2:19: Error: A non-null value must be returned since the return type 'invalid-type' doesn't allow null.
|
||||
Constraints get constraints {}
|
||||
^" in null;
|
||||
}
|
||||
get constraints() → invalid-type {}
|
||||
}
|
||||
abstract class RenderObjectWithChildMixin extends mai::RenderObject /*isMixinDeclaration*/ {
|
||||
}
|
||||
|
||||
@@ -38,10 +38,6 @@ library /*isNonNullableByDefault*/;
|
||||
// Constraints get constraints {}
|
||||
// ^^^^^^^^^^^
|
||||
//
|
||||
// pkg/front_end/testcases/general/crashes/crash_01/main_lib.dart:2:19: Error: A non-null value must be returned since the return type 'invalid-type' doesn't allow null.
|
||||
// Constraints get constraints {}
|
||||
// ^
|
||||
//
|
||||
import self as mai;
|
||||
import "dart:core" as core;
|
||||
|
||||
@@ -49,11 +45,7 @@ abstract class RenderObject extends core::Object {
|
||||
synthetic constructor •() → mai::RenderObject
|
||||
: super core::Object::•()
|
||||
;
|
||||
get constraints() → invalid-type {
|
||||
return let final Never #t1 = invalid-expression "pkg/front_end/testcases/general/crashes/crash_01/main_lib.dart:2:19: Error: A non-null value must be returned since the return type 'invalid-type' doesn't allow null.
|
||||
Constraints get constraints {}
|
||||
^" in null;
|
||||
}
|
||||
get constraints() → invalid-type {}
|
||||
}
|
||||
abstract class RenderObjectWithChildMixin extends mai::RenderObject /*isMixinDeclaration*/ {
|
||||
}
|
||||
|
||||
@@ -20,10 +20,6 @@ library /*isNonNullableByDefault*/;
|
||||
// co <{
|
||||
// ^^
|
||||
//
|
||||
// pkg/front_end/testcases/general/error_recovery/issue_39026.crash_dart:2:8: Error: A non-null value must be returned since the return type 'invalid-type' doesn't allow null.
|
||||
// co <{
|
||||
// ^
|
||||
//
|
||||
import self as self;
|
||||
import "dart:core" as core;
|
||||
|
||||
@@ -31,9 +27,5 @@ class A extends core::Object {
|
||||
synthetic constructor •() → self::A
|
||||
: super core::Object::•()
|
||||
;
|
||||
operator <() → invalid-type {
|
||||
return let final Never #t1 = invalid-expression "pkg/front_end/testcases/general/error_recovery/issue_39026.crash_dart:2:8: Error: A non-null value must be returned since the return type 'invalid-type' doesn't allow null.
|
||||
co <{
|
||||
^" in null;
|
||||
}
|
||||
operator <() → invalid-type {}
|
||||
}
|
||||
|
||||
+1
-9
@@ -20,10 +20,6 @@ library /*isNonNullableByDefault*/;
|
||||
// co <{
|
||||
// ^^
|
||||
//
|
||||
// pkg/front_end/testcases/general/error_recovery/issue_39026.crash_dart:2:8: Error: A non-null value must be returned since the return type 'invalid-type' doesn't allow null.
|
||||
// co <{
|
||||
// ^
|
||||
//
|
||||
import self as self;
|
||||
import "dart:core" as core;
|
||||
|
||||
@@ -31,9 +27,5 @@ class A extends core::Object {
|
||||
synthetic constructor •() → self::A
|
||||
: super core::Object::•()
|
||||
;
|
||||
operator <() → invalid-type {
|
||||
return let final Never #t1 = invalid-expression "pkg/front_end/testcases/general/error_recovery/issue_39026.crash_dart:2:8: Error: A non-null value must be returned since the return type 'invalid-type' doesn't allow null.
|
||||
co <{
|
||||
^" in null;
|
||||
}
|
||||
operator <() → invalid-type {}
|
||||
}
|
||||
|
||||
+1
-9
@@ -15,10 +15,6 @@ library /*isNonNullableByDefault*/;
|
||||
// co operator <{
|
||||
// ^^
|
||||
//
|
||||
// pkg/front_end/testcases/general/error_recovery/issue_39026_prime.crash_dart:2:17: Error: A non-null value must be returned since the return type 'invalid-type' doesn't allow null.
|
||||
// co operator <{
|
||||
// ^
|
||||
//
|
||||
import self as self;
|
||||
import "dart:core" as core;
|
||||
|
||||
@@ -26,9 +22,5 @@ class A extends core::Object {
|
||||
synthetic constructor •() → self::A
|
||||
: super core::Object::•()
|
||||
;
|
||||
operator <() → invalid-type {
|
||||
return let final Never #t1 = invalid-expression "pkg/front_end/testcases/general/error_recovery/issue_39026_prime.crash_dart:2:17: Error: A non-null value must be returned since the return type 'invalid-type' doesn't allow null.
|
||||
co operator <{
|
||||
^" in null;
|
||||
}
|
||||
operator <() → invalid-type {}
|
||||
}
|
||||
|
||||
+1
-9
@@ -15,10 +15,6 @@ library /*isNonNullableByDefault*/;
|
||||
// co operator <{
|
||||
// ^^
|
||||
//
|
||||
// pkg/front_end/testcases/general/error_recovery/issue_39026_prime.crash_dart:2:17: Error: A non-null value must be returned since the return type 'invalid-type' doesn't allow null.
|
||||
// co operator <{
|
||||
// ^
|
||||
//
|
||||
import self as self;
|
||||
import "dart:core" as core;
|
||||
|
||||
@@ -26,9 +22,5 @@ class A extends core::Object {
|
||||
synthetic constructor •() → self::A
|
||||
: super core::Object::•()
|
||||
;
|
||||
operator <() → invalid-type {
|
||||
return let final Never #t1 = invalid-expression "pkg/front_end/testcases/general/error_recovery/issue_39026_prime.crash_dart:2:17: Error: A non-null value must be returned since the return type 'invalid-type' doesn't allow null.
|
||||
co operator <{
|
||||
^" in null;
|
||||
}
|
||||
operator <() → invalid-type {}
|
||||
}
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user