Files
sdk/tests/utils/dummy_compiler_test.dart
T
ahe@google.com 1e0c2471a5 Changed default Uri constructor to Uri.fromComponents(), new default constructor is Uri.fromString(). This is to avoid new Uri('http://www.google.com') resulting in Uri with scheme='http://www.google.com'.
Committing on behalf of: Alexander Aprelev <aprelev@gmail.com>

BUG=dart-3348
TEST=new Uri('http://www.google.com') is the same as new Uri.fromString('http://www.google.com') same as new Uri.fromComponents(scheme:'http', domain:'www.google.com')

Review URL: https://chromiumcodereview.appspot.com//10850015

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@10168 260f80e4-7a28-3924-810f-c04153c831b5
2012-08-02 13:48:30 +00:00

60 lines
1.8 KiB
Dart

// Copyright (c) 2012, 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.
// Smoke test of the dart2js compiler API.
#import('../../lib/compiler/compiler.dart');
#import('dart:uri');
Future<String> provider(Uri uri) {
Completer<String> completer = new Completer<String>();
String source;
if (uri.scheme == "main") {
source = "main() {}";
} else if (uri.scheme == "lib") {
if (uri.path.endsWith("/core.dart")) {
source = """#library('core');
class Object{}
class bool {}
class num {}
class int {}
class double{}
class String{}
class Function{}
class List {}
class Closure {}
class Dynamic {}
class Null {}
getRuntimeTypeInfo(o) {}
setRuntimeTypeInfo(o, i) {}
eqNull(a) {}
eqNullB(a) {}""";
} else {
source = "#library('lib');";
}
} else {
throw "unexpected URI $uri";
}
completer.complete(source);
return completer.future;
}
void handler(Uri uri, int begin, int end, String message, Diagnostic kind) {
if (uri === null) {
print('$kind: $message');
} else {
print('$uri:$begin:$end: $kind: $message');
}
}
main() {
String code = compile(new Uri.fromComponents(scheme: 'main'),
new Uri.fromComponents(scheme: 'lib'),
new Uri.fromComponents(scheme: 'package'),
provider, handler).value;
if (code === null) {
throw 'Compilation failed';
}
}