OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <html> |
| 3 <body> |
| 4 <div id="result_shared_messages"></div> |
| 5 <div id="smoke_messages"></div> |
| 6 |
| 7 <script type="text/javascript" src="../lib/parser.js"></script> |
| 8 <script type="text/javascript"> |
| 9 var testRunner = window.testRunner; |
| 10 if (testRunner) testRunner.waitUntilDone(); |
| 11 |
| 12 var runningTestCount = 0; |
| 13 |
| 14 function success(div_id) { |
| 15 document.getElementById(div_id).innerText = "SUCCESS"; |
| 16 console.log("Reading messages: SUCCESS"); |
| 17 if (--runningTestCount == 0 && testRunner) testRunner.notifyDone(); |
| 18 } |
| 19 |
| 20 function fail(div_id, msg) { |
| 21 document.getElementById(div_id).innerText = "FAILED " + msg; |
| 22 console.log("Reading messages: FAILED " + msg); |
| 23 if (--runningTestCount == 0 && testRunner) testRunner.notifyDone(); |
| 24 } |
| 25 |
| 26 function runTest(uri, div_id, fun) { |
| 27 runningTestCount++; |
| 28 loadMessages(function(db) { |
| 29 try { |
| 30 fun(db); |
| 31 success(div_id); |
| 32 } catch (e) { |
| 33 fail(div_id, e); |
| 34 } |
| 35 }, function(e) { |
| 36 fail(div_id, e); |
| 37 }, uri); |
| 38 |
| 39 } |
| 40 |
| 41 runTest('../lib/shared_messages.dart', |
| 42 'result_shared_messages', |
| 43 function(db) { |
| 44 // No tests to run yet. |
| 45 return true; |
| 46 }); |
| 47 |
| 48 runTest('smoke_messages.dart', |
| 49 'smoke_messages', |
| 50 function(db) { |
| 51 if (!db['GENERIC']) throw "no GENERIC entry"; |
| 52 var entries = Object.keys(db); |
| 53 if (entries.length < 50) throw "not enough entries"; |
| 54 var entry = db['CANNOT_RESOLVE_IN_INITIALIZER']; |
| 55 if (!entry) throw "couldn't find entry"; |
| 56 var template = entry.template; |
| 57 if (template != |
| 58 "Cannot resolve '#{name}'. It would be implicitly looked up on this " + |
| 59 "instance, but instances are not available in initializers.") { |
| 60 throw "bad template"; |
| 61 } |
| 62 var howToFix = entry['howToFix']; |
| 63 if (!howToFix) throw "no how to fix"; |
| 64 if (howToFix != |
| 65 "Try correcting the unresolved reference or move the" + |
| 66 " initialization to a constructor body.") { |
| 67 throw "bad howtofix"; |
| 68 } |
| 69 var examples = entry['examples']; |
| 70 if (!examples) throw "no examples"; |
| 71 if (examples.length != 1) throw "bad length"; |
| 72 if (examples[0] != |
| 73 "class A {\n" + |
| 74 "var test = unresolvedName;\n" + |
| 75 "}\n" + |
| 76 "main() => new A();\n") { |
| 77 throw "bad example"; |
| 78 } |
| 79 }); |
| 80 </script> |
| 81 </body> |
| 82 </html> |
OLD | NEW |