Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 <!doctype html> | 1 <!doctype html> |
| 2 <!-- | 2 <!-- |
| 3 Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 3 Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 4 for details. All rights reserved. Use of this source code is governed by a | 4 for details. All rights reserved. Use of this source code is governed by a |
| 5 BSD-style license that can be found in the LICENSE file. | 5 BSD-style license that can be found in the LICENSE file. |
| 6 --> | 6 --> |
| 7 <html lang="en"> | 7 <html lang="en"> |
| 8 <head> | 8 <head> |
| 9 <meta charset="utf-8"> | 9 <meta charset="utf-8"> |
| 10 <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> | 10 <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> |
| 11 <title>watch_global_var_test</title> | |
| 12 <script type='application/javascript' src="testing.js"></script> | 11 <script type='application/javascript' src="testing.js"></script> |
| 13 </head> | 12 </head> |
| 14 <body> | 13 <body> |
| 15 <p>These two sentences should match:</p> | 14 <p>These two sentences should match:</p> |
| 16 <pre id="expected">The quick brown [fox, jumps] over the {lazy: dog}.</pre> | 15 <pre id="expected">The quick brown [fox, jumps] over the {lazy: dog}.</pre> |
| 17 <pre id="actual">The quick brown {{list}} over the {{map}}.</pre> | 16 <pre id="actual">The quick brown {{list}} over the {{map}}.</pre> |
| 18 <script type="application/dart"> | 17 <script type="application/dart"> |
| 19 import 'dart:html'; | 18 import 'dart:html'; |
| 20 import 'package:unittest/unittest.dart'; | 19 import 'package:unittest/unittest.dart'; |
| 21 import 'package:web_ui/watcher.dart'; | 20 import 'package:web_ui/observe.dart'; |
| 22 | 21 |
| 23 List list = ['initial', 'list state']; | 22 @observable |
| 24 Map map = {'initial': 'map', 'state': '!'}; | 23 List list = new ObservableList.from(['initial', 'list state']); |
|
Siggi Cherem (dart-lang)
2013/02/13 19:28:54
it might be worth providing a helper function that
Jennifer Messerly
2013/02/13 20:21:20
Yeah, it's bugging me too. But I dunno if that is
Siggi Cherem (dart-lang)
2013/02/13 20:41:13
sounds good - I think it also has value if we have
Jennifer Messerly
2013/02/14 00:38:09
went with toObservable, cleaned up everything!
| |
| 24 | |
| 25 @observable | |
| 26 Map map = new ObservableMap.from({'initial': 'map', 'state': '!'}); | |
| 27 | |
| 25 final expected = query('#expected'); | 28 final expected = query('#expected'); |
| 26 final actual = query('#actual'); | 29 final actual = query('#actual'); |
| 27 | 30 |
| 28 main() { | 31 main() { |
| 29 window.setTimeout(() { | 32 window.setTimeout(() { |
| 30 expect(actual.innerHtml, 'The quick brown [initial, list state] over ' | 33 expect(actual.innerHtml, 'The quick brown [initial, list state] over ' |
| 31 'the {initial: map, state: !}.'); | 34 'the {initial: map, state: !}.'); |
| 32 | 35 |
| 33 list[0] = 'fox'; | 36 list[0] = 'fox'; |
| 34 list[1] = 'jumps'; | 37 list[1] = 'jumps'; |
| 35 map.clear(); | 38 map.clear(); |
| 36 map['lazy'] = 'dog'; | 39 map['lazy'] = 'dog'; |
| 37 | 40 |
| 38 dispatch(); | 41 deliverChangesSync(); |
| 39 | 42 |
| 40 expect(actual.innerHtml, expected.innerHtml); | 43 expect(actual.innerHtml, expected.innerHtml); |
| 41 | 44 |
| 42 window.setTimeout(() => window.postMessage('done', '*'), 0); | 45 window.setImmediate(() => window.postMessage('done', '*')); |
| 43 }, 0); | 46 }, 0); |
| 44 } | 47 } |
| 45 </script> | 48 </script> |
| 46 </body> | 49 </body> |
| 47 </html> | 50 </html> |
| OLD | NEW |