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

Unified Diff: pkg/dart_messages/test/parser_test.html

Issue 1514333002: Add dart_messages package. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Minor fixes (long line...) Created 5 years 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
Index: pkg/dart_messages/test/parser_test.html
diff --git a/pkg/dart_messages/test/parser_test.html b/pkg/dart_messages/test/parser_test.html
new file mode 100644
index 0000000000000000000000000000000000000000..c0da9d2b0e11152d37748186d09d959c6070a89b
--- /dev/null
+++ b/pkg/dart_messages/test/parser_test.html
@@ -0,0 +1,82 @@
+<!DOCTYPE html>
+<html>
+<body>
+ <div id="result_shared_messages"></div>
+ <div id="smoke_messages"></div>
+
+ <script type="text/javascript" src="../lib/parser.js"></script>
+ <script type="text/javascript">
+ var testRunner = window.testRunner;
+ if (testRunner) testRunner.waitUntilDone();
+
+ var runningTestCount = 0;
+
+ function success(div_id) {
+ document.getElementById(div_id).innerText = "SUCCESS";
+ console.log("Reading messages: SUCCESS");
+ if (--runningTestCount == 0 && testRunner) testRunner.notifyDone();
+ }
+
+ function fail(div_id, msg) {
+ document.getElementById(div_id).innerText = "FAILED " + msg;
+ console.log("Reading messages: FAILED " + msg);
+ if (--runningTestCount == 0 && testRunner) testRunner.notifyDone();
+ }
+
+ function runTest(uri, div_id, fun) {
+ runningTestCount++;
+ loadMessages(function(db) {
+ try {
+ fun(db);
+ success(div_id);
+ } catch (e) {
+ fail(div_id, e);
+ }
+ }, function(e) {
+ fail(div_id, e);
+ }, uri);
+
+ }
+
+ runTest('../lib/shared_messages.dart',
+ 'result_shared_messages',
+ function(db) {
+ // No tests to run yet.
+ return true;
+ });
+
+ runTest('smoke_messages.dart',
+ 'smoke_messages',
+ function(db) {
+ if (!db['GENERIC']) throw "no GENERIC entry";
+ var entries = Object.keys(db);
+ if (entries.length < 50) throw "not enough entries";
+ var entry = db['CANNOT_RESOLVE_IN_INITIALIZER'];
+ if (!entry) throw "couldn't find entry";
+ var template = entry.template;
+ if (template !=
+ "Cannot resolve '#{name}'. It would be implicitly looked up on this " +
+ "instance, but instances are not available in initializers.") {
+ throw "bad template";
+ }
+ var howToFix = entry['howToFix'];
+ if (!howToFix) throw "no how to fix";
+ if (howToFix !=
+ "Try correcting the unresolved reference or move the" +
+ " initialization to a constructor body.") {
+ throw "bad howtofix";
+ }
+ var examples = entry['examples'];
+ if (!examples) throw "no examples";
+ if (examples.length != 1) throw "bad length";
+ if (examples[0] !=
+ "class A {\n" +
+ "var test = unresolvedName;\n" +
+ "}\n" +
+ "main() => new A();\n") {
+ throw "bad example";
+ }
+ });
+ </script>
+</body>
+</html>

Powered by Google App Engine
This is Rietveld 408576698