mirror of
https://github.com/dart-lang/sdk
synced 2024-09-19 23:51:47 +00:00
Add test of unittests.
BUG= R=sigurdm@google.com Review URL: https://codereview.chromium.org/1562023002.
This commit is contained in:
parent
812527f5b3
commit
306537be79
|
@ -435,7 +435,10 @@ class CompilerImpl extends Compiler {
|
|||
if (packages == null) {
|
||||
setupFutures.add(setupPackages(uri));
|
||||
}
|
||||
return Future.wait(setupFutures).then((_) => super.analyzeUri(uri));
|
||||
return Future.wait(setupFutures).then((_) {
|
||||
return super.analyzeUri(uri,
|
||||
skipLibraryWithPartOfTag: skipLibraryWithPartOfTag);
|
||||
});
|
||||
}
|
||||
|
||||
Future setupPackages(Uri uri) {
|
||||
|
|
|
@ -962,11 +962,10 @@ abstract class Compiler {
|
|||
{bool skipLibraryWithPartOfTag: true}) {
|
||||
assert(analyzeMain);
|
||||
reporter.log('Analyzing $libraryUri ($buildId)');
|
||||
return libraryLoader.loadLibrary(libraryUri).then((LibraryElement library) {
|
||||
var compilationUnit = library.compilationUnit;
|
||||
if (skipLibraryWithPartOfTag && compilationUnit.partTag != null) {
|
||||
return null;
|
||||
}
|
||||
return libraryLoader.loadLibrary(
|
||||
libraryUri, skipFileWithPartOfTag: true).then(
|
||||
(LibraryElement library) {
|
||||
if (library == null) return null;
|
||||
fullyEnqueueLibrary(library, enqueuer.resolution);
|
||||
emptyQueue(enqueuer.resolution);
|
||||
enqueuer.resolution.logSummary(reporter.log);
|
||||
|
|
|
@ -147,7 +147,13 @@ abstract class LibraryLoaderTask implements CompilerTask {
|
|||
/// [LibraryElement] for the library and computes the import/export scope,
|
||||
/// loading and computing the import/export scopes of all required libraries
|
||||
/// in the process. The method handles cyclic dependency between libraries.
|
||||
Future<LibraryElement> loadLibrary(Uri resolvedUri);
|
||||
///
|
||||
/// If [skipFileWithPartOfTag] is `true`, `null` is returned if the
|
||||
/// compilation unit for [resolvedUri] contains a `part of` tag. This is only
|
||||
/// used for analysis through [Compiler.analyzeUri].
|
||||
Future<LibraryElement> loadLibrary(
|
||||
Uri resolvedUri,
|
||||
{bool skipFileWithPartOfTag: false});
|
||||
|
||||
/// Reset the library loader task to prepare for compilation. If provided,
|
||||
/// libraries matching [reuseLibrary] are reused.
|
||||
|
@ -339,18 +345,27 @@ class _LibraryLoaderTask extends CompilerTask implements LibraryLoaderTask {
|
|||
Uri resourceUri = library.entryCompilationUnit.script.resourceUri;
|
||||
libraryResourceUriMap[resourceUri] = library;
|
||||
|
||||
String name = library.libraryOrScriptName;
|
||||
libraryNames[name] = library;
|
||||
if (library.hasLibraryName) {
|
||||
String name = library.libraryName;
|
||||
libraryNames[name] = library;
|
||||
}
|
||||
}
|
||||
|
||||
Future<LibraryElement> loadLibrary(Uri resolvedUri) {
|
||||
Future<LibraryElement> loadLibrary(
|
||||
Uri resolvedUri,
|
||||
{bool skipFileWithPartOfTag: false}) {
|
||||
return measure(() {
|
||||
assert(currentHandler == null);
|
||||
// TODO(johnniwinther): Ensure that currentHandler correctly encloses the
|
||||
// loading of a library cluster.
|
||||
currentHandler = new LibraryDependencyHandler(this);
|
||||
return createLibrary(currentHandler, null, resolvedUri)
|
||||
return createLibrary(currentHandler, null, resolvedUri,
|
||||
skipFileWithPartOfTag: skipFileWithPartOfTag)
|
||||
.then((LibraryElement library) {
|
||||
if (library == null) {
|
||||
currentHandler = null;
|
||||
return null;
|
||||
}
|
||||
return reporter.withCurrentElement(library, () {
|
||||
return measure(() {
|
||||
currentHandler.computeExports();
|
||||
|
@ -506,7 +521,7 @@ class _LibraryLoaderTask extends CompilerTask implements LibraryLoaderTask {
|
|||
'canonicalUri2': existing.canonicalUri});
|
||||
}
|
||||
} else if (library.hasLibraryName) {
|
||||
String name = library.libraryOrScriptName;
|
||||
String name = library.libraryName;
|
||||
existing = libraryNames.putIfAbsent(name, () => library);
|
||||
if (!identical(existing, library)) {
|
||||
reporter.withCurrentElement(library, () {
|
||||
|
@ -563,7 +578,7 @@ class _LibraryLoaderTask extends CompilerTask implements LibraryLoaderTask {
|
|||
LibraryDependencyElementX libraryDependency) {
|
||||
Uri base = library.canonicalUri;
|
||||
Uri resolvedUri = base.resolveUri(libraryDependency.uri);
|
||||
return createLibrary(handler, library, resolvedUri, libraryDependency)
|
||||
return createLibrary(handler, library, resolvedUri, node: libraryDependency)
|
||||
.then((LibraryElement loadedLibrary) {
|
||||
if (loadedLibrary == null) return;
|
||||
reporter.withCurrentElement(library, () {
|
||||
|
@ -600,10 +615,12 @@ class _LibraryLoaderTask extends CompilerTask implements LibraryLoaderTask {
|
|||
*
|
||||
* If a new library is created, the [handler] is notified.
|
||||
*/
|
||||
Future<LibraryElement> createLibrary(LibraryDependencyHandler handler,
|
||||
LibraryElement importingLibrary,
|
||||
Uri resolvedUri,
|
||||
[Spannable node]) {
|
||||
Future<LibraryElement> createLibrary(
|
||||
LibraryDependencyHandler handler,
|
||||
LibraryElement importingLibrary,
|
||||
Uri resolvedUri,
|
||||
{Spannable node,
|
||||
bool skipFileWithPartOfTag: false}) {
|
||||
Uri readableUri =
|
||||
compiler.translateResolvedUri(importingLibrary, resolvedUri, node);
|
||||
LibraryElement library = libraryCanonicalUriMap[resolvedUri];
|
||||
|
@ -626,6 +643,12 @@ class _LibraryLoaderTask extends CompilerTask implements LibraryLoaderTask {
|
|||
createLibrarySync(handler, script, resolvedUri);
|
||||
CompilationUnitElementX compilationUnit = element.entryCompilationUnit;
|
||||
if (compilationUnit.partTag != null) {
|
||||
if (skipFileWithPartOfTag) {
|
||||
// TODO(johnniwinther): Avoid calling [Compiler.onLibraryCreated]
|
||||
// for this library.
|
||||
libraryCanonicalUriMap.remove(resolvedUri);
|
||||
return null;
|
||||
}
|
||||
DiagnosticMessage error = reporter.withCurrentElement(
|
||||
compilationUnit,
|
||||
() => reporter.createMessage(
|
||||
|
|
|
@ -29,5 +29,5 @@ void main() {
|
|||
uriList.add(new Uri(scheme: 'dart', path: name));
|
||||
}
|
||||
});
|
||||
asyncTest(() => analyze(uriList, WHITE_LIST));
|
||||
asyncTest(() => analyze(uriList, WHITE_LIST, mode: AnalysisMode.ALL));
|
||||
}
|
||||
|
|
|
@ -10,7 +10,8 @@ import 'package:compiler/compiler.dart' as api;
|
|||
import 'package:compiler/src/apiimpl.dart';
|
||||
import 'package:compiler/src/commandline_options.dart';
|
||||
import 'package:compiler/src/diagnostics/messages.dart' show
|
||||
Message;
|
||||
Message,
|
||||
MessageKind;
|
||||
import 'package:compiler/src/filenames.dart';
|
||||
import 'package:compiler/src/source_file_provider.dart';
|
||||
import 'package:compiler/src/util/uri_extras.dart';
|
||||
|
@ -33,15 +34,16 @@ class CollectingDiagnosticHandler extends FormattingDiagnosticHandler {
|
|||
bool hasErrors = false;
|
||||
bool lastWasWhitelisted = false;
|
||||
|
||||
Map<String, Map<String, int>> whiteListMap
|
||||
= new Map<String, Map<String, int>>();
|
||||
Map<String, Map<dynamic/*String|MessageKind*/, int>> whiteListMap
|
||||
= new Map<String, Map<dynamic/*String|MessageKind*/, int>>();
|
||||
|
||||
CollectingDiagnosticHandler(Map<String, List<String>> whiteList,
|
||||
SourceFileProvider provider)
|
||||
CollectingDiagnosticHandler(
|
||||
Map<String, List/*<String|MessageKind>*/> whiteList,
|
||||
SourceFileProvider provider)
|
||||
: super(provider) {
|
||||
whiteList.forEach((String file, List<String> messageParts) {
|
||||
var useMap = new Map<String,int>();
|
||||
for (String messagePart in messageParts) {
|
||||
whiteList.forEach((String file, List/*<String|MessageKind>*/ messageParts) {
|
||||
var useMap = new Map<dynamic/*String|MessageKind*/, int>();
|
||||
for (var messagePart in messageParts) {
|
||||
useMap[messagePart] = 0;
|
||||
}
|
||||
whiteListMap[file] = useMap;
|
||||
|
@ -57,7 +59,7 @@ class CollectingDiagnosticHandler extends FormattingDiagnosticHandler {
|
|||
bool checkWhiteListUse() {
|
||||
bool allUsed = true;
|
||||
for (String file in whiteListMap.keys) {
|
||||
for (String messagePart in whiteListMap[file].keys) {
|
||||
for (var messagePart in whiteListMap[file].keys) {
|
||||
if (whiteListMap[file][messagePart] == 0) {
|
||||
print("Whitelisting '$messagePart' is unused in '$file'. "
|
||||
"Remove the whitelisting from the whitelist map.");
|
||||
|
@ -70,7 +72,7 @@ class CollectingDiagnosticHandler extends FormattingDiagnosticHandler {
|
|||
|
||||
void reportWhiteListUse() {
|
||||
for (String file in whiteListMap.keys) {
|
||||
for (String messagePart in whiteListMap[file].keys) {
|
||||
for (var messagePart in whiteListMap[file].keys) {
|
||||
int useCount = whiteListMap[file][messagePart];
|
||||
print("Whitelisted message '$messagePart' suppressed $useCount "
|
||||
"time(s) in '$file'.");
|
||||
|
@ -78,15 +80,22 @@ class CollectingDiagnosticHandler extends FormattingDiagnosticHandler {
|
|||
}
|
||||
}
|
||||
|
||||
bool checkWhiteList(Uri uri, String message) {
|
||||
bool checkWhiteList(Uri uri, Message message, String text) {
|
||||
if (uri == null) {
|
||||
return false;
|
||||
}
|
||||
String path = uri.path;
|
||||
for (String file in whiteListMap.keys) {
|
||||
if (path.contains(file)) {
|
||||
for (String messagePart in whiteListMap[file].keys) {
|
||||
if (message.contains(messagePart)) {
|
||||
for (var messagePart in whiteListMap[file].keys) {
|
||||
bool found = false;
|
||||
if (messagePart is String) {
|
||||
found = text.contains(messagePart);
|
||||
} else {
|
||||
assert(messagePart is MessageKind);
|
||||
found = message.kind == messagePart;
|
||||
}
|
||||
if (found) {
|
||||
whiteListMap[file][messagePart]++;
|
||||
return true;
|
||||
}
|
||||
|
@ -100,7 +109,7 @@ class CollectingDiagnosticHandler extends FormattingDiagnosticHandler {
|
|||
void report(Message message, Uri uri, int begin, int end, String text,
|
||||
api.Diagnostic kind) {
|
||||
if (kind == api.Diagnostic.WARNING) {
|
||||
if (checkWhiteList(uri, text)) {
|
||||
if (checkWhiteList(uri, message, text)) {
|
||||
// Suppress whitelisted warnings.
|
||||
lastWasWhitelisted = true;
|
||||
return;
|
||||
|
@ -108,7 +117,7 @@ class CollectingDiagnosticHandler extends FormattingDiagnosticHandler {
|
|||
hasWarnings = true;
|
||||
}
|
||||
if (kind == api.Diagnostic.HINT) {
|
||||
if (checkWhiteList(uri, text)) {
|
||||
if (checkWhiteList(uri, message, text)) {
|
||||
// Suppress whitelisted hints.
|
||||
lastWasWhitelisted = true;
|
||||
return;
|
||||
|
@ -116,7 +125,7 @@ class CollectingDiagnosticHandler extends FormattingDiagnosticHandler {
|
|||
hasHint = true;
|
||||
}
|
||||
if (kind == api.Diagnostic.ERROR) {
|
||||
if (checkWhiteList(uri, text)) {
|
||||
if (checkWhiteList(uri, message, text)) {
|
||||
// Suppress whitelisted errors.
|
||||
lastWasWhitelisted = true;
|
||||
return;
|
||||
|
@ -134,11 +143,22 @@ class CollectingDiagnosticHandler extends FormattingDiagnosticHandler {
|
|||
typedef bool CheckResults(CompilerImpl compiler,
|
||||
CollectingDiagnosticHandler handler);
|
||||
|
||||
enum AnalysisMode {
|
||||
/// Analyze all declarations in all libraries in one go.
|
||||
ALL,
|
||||
/// Analyze all declarations in the main library.
|
||||
MAIN,
|
||||
/// Analyze all declarations in the given URIs one at a time. This mode can
|
||||
/// handle URIs for parts (i.e. skips these).
|
||||
URI,
|
||||
/// Analyze all declarations reachable from the entry point.
|
||||
TREE_SHAKING,
|
||||
}
|
||||
|
||||
Future analyze(List<Uri> uriList,
|
||||
Map<String, List<String>> whiteList,
|
||||
{bool analyzeAll: true,
|
||||
bool analyzeMain: false,
|
||||
CheckResults checkResults}) {
|
||||
Map<String, List/*<String|MessageKind>*/> whiteList,
|
||||
{AnalysisMode mode: AnalysisMode.ALL,
|
||||
CheckResults checkResults}) async {
|
||||
String testFileName =
|
||||
relativize(Uri.base, Platform.script, Platform.isWindows);
|
||||
|
||||
|
@ -159,8 +179,17 @@ Future analyze(List<Uri> uriList,
|
|||
var handler = new CollectingDiagnosticHandler(whiteList, provider);
|
||||
var options = <String>[Flags.analyzeOnly, '--categories=Client,Server',
|
||||
Flags.showPackageWarnings];
|
||||
if (analyzeAll) options.add(Flags.analyzeAll);
|
||||
if (analyzeMain) options.add(Flags.analyzeMain);
|
||||
switch (mode) {
|
||||
case AnalysisMode.URI:
|
||||
case AnalysisMode.MAIN:
|
||||
options.add(Flags.analyzeMain);
|
||||
break;
|
||||
case AnalysisMode.ALL:
|
||||
options.add(Flags.analyzeAll);
|
||||
break;
|
||||
case AnalysisMode.TREE_SHAKING:
|
||||
break;
|
||||
}
|
||||
var compiler = new CompilerImpl(
|
||||
provider,
|
||||
null,
|
||||
|
@ -179,22 +208,25 @@ Future analyze(List<Uri> uriList,
|
|||
===
|
||||
""";
|
||||
|
||||
void onCompletion(_) {
|
||||
bool result;
|
||||
if (checkResults != null) {
|
||||
result = checkResults(compiler, handler);
|
||||
} else {
|
||||
result = handler.checkResults();
|
||||
if (mode == AnalysisMode.URI) {
|
||||
for (Uri uri in uriList) {
|
||||
await compiler.analyzeUri(uri);
|
||||
}
|
||||
if (!result) {
|
||||
print(MESSAGE);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
if (analyzeAll || analyzeMain) {
|
||||
} else if (mode != AnalysisMode.TREE_SHAKING) {
|
||||
compiler.librariesToAnalyzeWhenRun = uriList;
|
||||
return compiler.run(null).then(onCompletion);
|
||||
await compiler.run(null);
|
||||
} else {
|
||||
return compiler.run(uriList.single).then(onCompletion);
|
||||
await compiler.run(uriList.single);
|
||||
}
|
||||
|
||||
bool result;
|
||||
if (checkResults != null) {
|
||||
result = checkResults(compiler, handler);
|
||||
} else {
|
||||
result = handler.checkResults();
|
||||
}
|
||||
if (!result) {
|
||||
print(MESSAGE);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
|
81
tests/compiler/dart2js/analyze_test_test.dart
Normal file
81
tests/compiler/dart2js/analyze_test_test.dart
Normal file
|
@ -0,0 +1,81 @@
|
|||
// Copyright (c) 2016, 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 dart2js.analyze_test.test;
|
||||
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:async_helper/async_helper.dart';
|
||||
import 'package:compiler/src/apiimpl.dart' show
|
||||
CompilerImpl;
|
||||
import 'package:compiler/src/commandline_options.dart';
|
||||
import 'package:compiler/src/diagnostics/messages.dart' show
|
||||
MessageKind;
|
||||
import 'package:compiler/src/filenames.dart' show
|
||||
nativeToUriPath;
|
||||
|
||||
import 'analyze_helper.dart';
|
||||
import 'memory_compiler.dart';
|
||||
|
||||
/**
|
||||
* Map of white-listed warnings and errors.
|
||||
*
|
||||
* Use an identifiable suffix of the file uri as key. Use a fixed substring of
|
||||
* the error/warning message in the list of white-listings for each file.
|
||||
*/
|
||||
// TODO(johnniwinther): Support canonical URIs as keys and message kinds as
|
||||
// values.
|
||||
const Map<String, List/*<String|MessageKind>*/> WHITE_LIST = const {
|
||||
"analyze_all_test.dart": const [
|
||||
MessageKind.IMPORT_EXPERIMENTAL_MIRRORS,
|
||||
],
|
||||
"/test/src/util/": const [
|
||||
"Library 'package:async/async.dart' doesn't export a "
|
||||
"'ForkableStream' declaration.",
|
||||
],
|
||||
"mirrors_test.dart": const [
|
||||
MessageKind.INVALID_SYMBOL,
|
||||
MessageKind.PRIVATE_IDENTIFIER,
|
||||
],
|
||||
};
|
||||
|
||||
const List<String> SKIP_LIST = const <String>[
|
||||
// Helper files:
|
||||
"dart2js_batch2_run.dart",
|
||||
"http_launch_data/",
|
||||
"mirrors_helper.dart",
|
||||
"path%20with%20spaces/",
|
||||
"one_line_dart_program.dart",
|
||||
"sourcemaps/invokes_test_file.dart",
|
||||
// No longer maintained:
|
||||
"backend_dart/",
|
||||
// Broken tests:
|
||||
"http_test.dart",
|
||||
];
|
||||
|
||||
main(List<String> arguments) {
|
||||
bool verbose = arguments.contains('-v');
|
||||
|
||||
List<String> options = <String>[
|
||||
Flags.analyzeOnly,
|
||||
Flags.analyzeMain,
|
||||
'--categories=Client,Server'];
|
||||
if (verbose) {
|
||||
options.add(Flags.verbose);
|
||||
}
|
||||
asyncTest(() async {
|
||||
List<Uri> uriList = <Uri>[];
|
||||
Directory dir =
|
||||
new Directory.fromUri(Uri.base.resolve('tests/compiler/dart2js/'));
|
||||
for (FileSystemEntity entity in dir.listSync(recursive: true)) {
|
||||
if (entity is File && entity.path.endsWith('.dart')) {
|
||||
Uri file = Uri.base.resolve(nativeToUriPath(entity.path));
|
||||
if (!SKIP_LIST.any((skip) => file.path.contains(skip))) {
|
||||
uriList.add(file);
|
||||
}
|
||||
}
|
||||
}
|
||||
await analyze(uriList, WHITE_LIST, mode: AnalysisMode.URI);
|
||||
});
|
||||
}
|
|
@ -76,7 +76,7 @@ void main() {
|
|||
// TODO(johnniwinther): Use [WHITE_LIST] again when
|
||||
// [Compiler.reportUnusedCode] is reenabled.
|
||||
const {}, // WHITE_LIST
|
||||
analyzeAll: false,
|
||||
mode: AnalysisMode.TREE_SHAKING,
|
||||
checkResults: checkResults));
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
// Test that the compiler can handle imports when package root has not been set.
|
||||
|
||||
library dart2js.test.missing_file;
|
||||
library dart2js.test.bad_output_io;
|
||||
|
||||
import 'dart:io' show exit;
|
||||
import 'package:expect/expect.dart';
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
// 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 boolified_operator_test;
|
||||
library boolify_test;
|
||||
|
||||
import 'package:expect/expect.dart';
|
||||
import 'package:async_helper/async_helper.dart';
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
// Test for iterators on for [SubclassNode].
|
||||
|
||||
library world_test;
|
||||
library class_set_test;
|
||||
|
||||
import 'package:expect/expect.dart';
|
||||
import 'package:async_helper/async_helper.dart';
|
||||
|
|
|
@ -24,7 +24,8 @@ main() async {
|
|||
});
|
||||
asyncTest(() async {
|
||||
analyze(uriList, {},
|
||||
checkResults: checkResults, analyzeMain: true, analyzeAll: false);
|
||||
checkResults: checkResults,
|
||||
mode: AnalysisMode.MAIN);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
// 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 subtype_test;
|
||||
library flatten_test;
|
||||
|
||||
import 'package:expect/expect.dart';
|
||||
import "package:async_helper/async_helper.dart";
|
||||
|
|
|
@ -35,7 +35,7 @@ main() {
|
|||
String name = 'foo';
|
||||
var element = cls.lookupLocalMember(name);
|
||||
Expect.isNotNull(element);
|
||||
Selector selector = new Selector.getter(name, null);
|
||||
Selector selector = new Selector.getter(new PublicName(name));
|
||||
Expect.isFalse(compiler.world.hasAnyUserDefinedGetter(selector, null));
|
||||
}));
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
// Test that the compiler emits a warning on import of 'dart:mirrors' unless
|
||||
// the flag --enable-experimental-mirrors is used.
|
||||
|
||||
library dart2js.test.import;
|
||||
library dart2js.test.import_mirrors;
|
||||
|
||||
import 'dart:async';
|
||||
import 'package:expect/expect.dart';
|
||||
|
|
|
@ -9,8 +9,9 @@ library dart2js.test.send_measurements_test;
|
|||
import 'dart:async';
|
||||
import 'package:test/test.dart';
|
||||
import 'package:dart2js_info/info.dart';
|
||||
import 'package:dart2js_info/src/util.dart' show
|
||||
recursiveDiagnosticString;
|
||||
import 'memory_compiler.dart';
|
||||
import 'dart:io';
|
||||
|
||||
main() {
|
||||
test('nothing is reachable, nothing to count', () {
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
// Tests for constant folding and lowering String.codeUnitAt.
|
||||
|
||||
library basic_tests;
|
||||
library codeUnitAt_tests;
|
||||
|
||||
import 'js_backend_cps_ir.dart';
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
// Test that the GVN optimization pass works as expected.
|
||||
|
||||
library basic_tests;
|
||||
library gvn_tests;
|
||||
|
||||
import 'js_backend_cps_ir.dart';
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
// Tests of operators.
|
||||
|
||||
library operators_tests;
|
||||
library operators2_tests;
|
||||
|
||||
import 'js_backend_cps_ir.dart';
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
// Tests for the runtime type implementation.
|
||||
|
||||
library basic_tests;
|
||||
library runtime_types_tests;
|
||||
|
||||
import 'js_backend_cps_ir.dart';
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@ import 'memory_compiler.dart';
|
|||
import 'package:compiler/src/cps_ir/cps_ir_nodes.dart' as ir;
|
||||
import 'package:compiler/src/cps_ir/cps_ir_nodes_sexpr.dart' as ir;
|
||||
import 'package:compiler/src/js/js.dart' as js;
|
||||
import 'package:compiler/src/js_backend/js_backend.dart';
|
||||
import 'package:compiler/src/elements/elements.dart';
|
||||
|
||||
const String TEST_MAIN_FILE = 'test.dart';
|
||||
|
@ -78,8 +79,9 @@ runTests(List<TestEntry> tests) {
|
|||
}
|
||||
|
||||
Uri uri = Uri.parse('memory:$TEST_MAIN_FILE');
|
||||
compiler.backend.functionCompiler.cpsBuilderTask.builderCallback =
|
||||
cacheIrNodeForMain;
|
||||
JavaScriptBackend backend = compiler.backend;
|
||||
var functionCompiler = backend.functionCompiler;
|
||||
functionCompiler.cpsBuilderTask.builderCallback = cacheIrNodeForMain;
|
||||
|
||||
return compiler.run(uri).then((bool success) {
|
||||
Expect.isTrue(success);
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
// 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 subtype_test;
|
||||
library least_upper_bound_test;
|
||||
|
||||
import 'package:expect/expect.dart';
|
||||
import 'package:async_helper/async_helper.dart';
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
// 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 subtype_test;
|
||||
library lookup_member_test;
|
||||
|
||||
import 'package:expect/expect.dart';
|
||||
import "package:async_helper/async_helper.dart";
|
||||
|
|
|
@ -8,11 +8,18 @@ import 'package:expect/expect.dart';
|
|||
import "package:async_helper/async_helper.dart";
|
||||
import 'type_test_helper.dart';
|
||||
import 'package:compiler/src/dart_types.dart';
|
||||
import "package:compiler/src/elements/elements.dart"
|
||||
show Element, ClassElement, MemberSignature, Name, PublicName,
|
||||
DeclaredMember, Member;
|
||||
import "package:compiler/src/resolution/class_members.dart"
|
||||
show MembersCreator, DeclaredMember, ErroneousMember, SyntheticMember;
|
||||
import "package:compiler/src/elements/elements.dart" show
|
||||
Element,
|
||||
ClassElement,
|
||||
MemberSignature,
|
||||
Name,
|
||||
PublicName,
|
||||
Member;
|
||||
import "package:compiler/src/resolution/class_members.dart" show
|
||||
MembersCreator,
|
||||
DeclaredMember,
|
||||
ErroneousMember,
|
||||
SyntheticMember;
|
||||
|
||||
void main() {
|
||||
testClassMembers();
|
||||
|
|
|
@ -124,7 +124,8 @@ Future<Compiler> check(MessageTemplate template, Compiler cachedCompiler) {
|
|||
Expect.isTrue(messageFound,
|
||||
'${template.kind}} does not match any in\n '
|
||||
'${messages.join('\n ')}');
|
||||
Expect.isFalse(compiler.reporter.hasCrashed);
|
||||
var reporter = compiler.reporter;
|
||||
Expect.isFalse(reporter.hasCrashed);
|
||||
if (!unexpectedMessages.isEmpty) {
|
||||
for (CollectedMessage message in unexpectedMessages) {
|
||||
print("Unexpected message: $message");
|
||||
|
|
|
@ -27,7 +27,8 @@ class SourceMirrorsReader extends MirrorsReader {
|
|||
try {
|
||||
return f();
|
||||
} on SpannableAssertionFailure catch (e) {
|
||||
mirrorSystem.compiler.reportAssertionFailure(e);
|
||||
var reporter = mirrorSystem.compiler.reporter;
|
||||
reporter.reportAssertionFailure(e);
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
// 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 dart2js.test.memory_source_file_helper;
|
||||
library dart2js.test.mirrors_lookup;
|
||||
|
||||
import 'package:expect/expect.dart';
|
||||
import "package:async_helper/async_helper.dart";
|
||||
|
|
|
@ -155,19 +155,23 @@ void testConditionalExpression() {
|
|||
}
|
||||
|
||||
void testNullOperators() {
|
||||
Expression node = parseStatement("a ?? b;").expression;
|
||||
ExpressionStatement statement = parseStatement("a ?? b;");
|
||||
Expression node = statement.expression;
|
||||
Expect.isNotNull(node.asSend());
|
||||
Expect.isTrue(node.asSend().isIfNull);
|
||||
|
||||
node = parseStatement("a ??= b;").expression;
|
||||
statement = parseStatement("a ??= b;");
|
||||
node = statement.expression;
|
||||
Expect.isNotNull(node.asSendSet());
|
||||
Expect.isTrue(node.asSendSet().isIfNullAssignment);
|
||||
|
||||
node = parseStatement("a?.b;").expression;
|
||||
statement = parseStatement("a?.b;");
|
||||
node = statement.expression;
|
||||
Expect.isNotNull(node.asSend());
|
||||
Expect.isTrue(node.asSend().isConditional);
|
||||
|
||||
node = parseStatement("a?.m();").expression;
|
||||
statement = parseStatement("a?.m();");
|
||||
node = statement.expression;
|
||||
Expect.isNotNull(node.asSend());
|
||||
Expect.isTrue(node.asSend().isConditional);
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
// 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 related_types;
|
||||
library related_types.test;
|
||||
|
||||
import 'package:async_helper/async_helper.dart';
|
||||
import 'package:expect/expect.dart';
|
||||
|
|
|
@ -198,8 +198,10 @@ Future testTypeVariables() {
|
|||
'}');
|
||||
ClassElement foo = compiler.mainApp.find('Foo');
|
||||
foo.ensureResolved(compiler.resolution);
|
||||
foo.lookupLocalMember('t').computeType(compiler.resolution);
|
||||
foo.lookupLocalMember('foo').computeType(compiler.resolution);
|
||||
MemberElement tMember = foo.lookupLocalMember('t');
|
||||
tMember.computeType(compiler.resolution);
|
||||
MemberElement fooMember = foo.lookupLocalMember('foo');
|
||||
fooMember.computeType(compiler.resolution);
|
||||
compiler.resolver.resolve(foo.lookupLocalMember('bar'));
|
||||
DiagnosticCollector collector = compiler.diagnosticCollector;
|
||||
Expect.equals(0, collector.warnings.length);
|
||||
|
|
|
@ -8,7 +8,7 @@ import 'dart:async';
|
|||
|
||||
import 'package:path/path.dart' as path;
|
||||
import 'package:expect/expect.dart';
|
||||
import 'package:source_maps/source_maps.dart' hide SourceFile;
|
||||
import 'package:source_maps/source_maps.dart';
|
||||
import 'package:compiler/src/apiimpl.dart';
|
||||
import 'package:compiler/src/elements/elements.dart'
|
||||
show AstElement,
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
/// Utility library for creating web colors.
|
||||
|
||||
library colors;
|
||||
library sourcemaps.colors;
|
||||
|
||||
/// A web color.
|
||||
abstract class Color {
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
// Test for iterators on for [SubclassNode].
|
||||
|
||||
library world_test;
|
||||
library subtypeset_test;
|
||||
|
||||
import 'package:expect/expect.dart';
|
||||
import 'package:async_helper/async_helper.dart';
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
// 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 subtype_test;
|
||||
library type_order_test;
|
||||
|
||||
import 'package:expect/expect.dart';
|
||||
import 'package:async_helper/async_helper.dart';
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
// 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 subtype_test;
|
||||
library type_representation_test;
|
||||
|
||||
import 'package:expect/expect.dart';
|
||||
import "package:async_helper/async_helper.dart";
|
||||
|
|
|
@ -14,6 +14,7 @@ import 'package:compiler/src/compiler.dart'
|
|||
show Compiler;
|
||||
import 'package:compiler/src/elements/elements.dart'
|
||||
show Element,
|
||||
MemberElement,
|
||||
TypeDeclarationElement,
|
||||
ClassElement;
|
||||
|
||||
|
@ -96,7 +97,8 @@ class TypeEnvironment {
|
|||
}
|
||||
|
||||
DartType getElementType(String name) {
|
||||
return getElement(name).computeType(compiler.resolution);
|
||||
var element = getElement(name);
|
||||
return element.computeType(compiler.resolution);
|
||||
}
|
||||
|
||||
DartType operator[] (String name) {
|
||||
|
@ -106,7 +108,7 @@ class TypeEnvironment {
|
|||
}
|
||||
|
||||
DartType getMemberType(ClassElement element, String name) {
|
||||
Element member = element.localLookup(name);
|
||||
MemberElement member = element.localLookup(name);
|
||||
return member.computeType(compiler.resolution);
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
// 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 subtype_test;
|
||||
library type_variable_occurrence_test;
|
||||
|
||||
import 'package:expect/expect.dart';
|
||||
import "package:async_helper/async_helper.dart";
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
// 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 test.library_imports;
|
||||
library test.library_exports_hidden;
|
||||
|
||||
import 'dart:mirrors';
|
||||
import 'package:expect/expect.dart';
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
// 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 test.library_imports;
|
||||
library test.library_exports_shown;
|
||||
|
||||
import 'dart:mirrors';
|
||||
import 'package:expect/expect.dart';
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
// 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 test.library_imports;
|
||||
library test.library_imports_hidden;
|
||||
|
||||
import 'dart:mirrors';
|
||||
import 'package:expect/expect.dart';
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
// 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 test.library_imports;
|
||||
library test.library_imports_prefixed_show_hide;
|
||||
|
||||
import 'dart:mirrors';
|
||||
import 'package:expect/expect.dart';
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
// 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 test.library_imports;
|
||||
library test.library_imports_prefixed;
|
||||
|
||||
import 'dart:mirrors';
|
||||
import 'package:expect/expect.dart';
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
// 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 test.library_imports;
|
||||
library test.library_imports_shown;
|
||||
|
||||
import 'dart:mirrors';
|
||||
import 'package:expect/expect.dart';
|
||||
|
|
Loading…
Reference in a new issue