Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(232)

Unified Diff: test/typecheck.dart

Issue 2465893002: Add strong mode type checking pass. (Closed)
Patch Set: Merge with master and remove visitBlockExpression Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « test/baseline_type_propagation_test.dart ('k') | testcases/strong-mode/DeltaBlue.baseline.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/typecheck.dart
diff --git a/test/typecheck.dart b/test/typecheck.dart
new file mode 100644
index 0000000000000000000000000000000000000000..a02815ab0519cb73f43b92176ab2e417e35239a0
--- /dev/null
+++ b/test/typecheck.dart
@@ -0,0 +1,44 @@
+// 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.
+import 'package:kernel/kernel.dart';
+import 'package:kernel/class_hierarchy.dart';
+import 'package:kernel/core_types.dart';
+import 'package:kernel/type_checker.dart';
+import 'dart:io';
+
+final String usage = '''
+Usage: typecheck FILE.dill
+
+Runs the strong mode type checker on the given program.
+''';
+
+main(List<String> args) {
+ if (args.length != 1) {
+ print(usage);
+ exit(1);
+ }
+ var program = loadProgramFromBinary(args[0]);
+ var coreTypes = new CoreTypes(program);
+ var hierarchy = new ClassHierarchy(program);
+ new TestTypeChecker(coreTypes, hierarchy).checkProgram(program);
+}
+
+class TestTypeChecker extends TypeChecker {
+ TestTypeChecker(CoreTypes coreTypes, ClassHierarchy hierarchy)
+ : super(coreTypes, hierarchy);
+
+ @override
+ void checkAssignable(TreeNode where, DartType from, DartType to) {
+ if (!environment.isSubtypeOf(from, to)) {
+ fail(where, '$from is not a subtype of $to');
+ }
+ }
+
+ @override
+ void fail(TreeNode where, String message) {
+ Location location = where.location;
+ String locationString = location == null ? '' : '($location)';
+ print('[error] $message $locationString');
+ }
+}
« no previous file with comments | « test/baseline_type_propagation_test.dart ('k') | testcases/strong-mode/DeltaBlue.baseline.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698