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

Side by Side Diff: pkg/polymer_expressions/test/syntax_test.dart

Issue 24031006: Silently handle handle eval exceptions in PolymerExpressions (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 3 months 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 import 'dart:async'; 5 import 'dart:async';
6 import 'dart:html'; 6 import 'dart:html';
7 7
8 import 'package:mdv/mdv.dart' as mdv;
9 import 'package:logging/logging.dart';
10 import 'package:observe/observe.dart';
8 import 'package:polymer_expressions/polymer_expressions.dart'; 11 import 'package:polymer_expressions/polymer_expressions.dart';
12 import 'package:unittest/html_enhanced_config.dart';
9 import 'package:unittest/unittest.dart'; 13 import 'package:unittest/unittest.dart';
10 import 'package:unittest/html_enhanced_config.dart';
11 import 'package:observe/observe.dart';
12 import 'package:mdv/mdv.dart' as mdv;
13 14
14 main() { 15 main() {
15 mdv.initialize(); 16 mdv.initialize();
16 useHtmlEnhancedConfiguration(); 17 useHtmlEnhancedConfiguration();
17 18
18 group('PolymerExpressions', () { 19 group('PolymerExpressions', () {
19 var testDiv; 20 var testDiv;
20 21
21 setUp(() { 22 setUp(() {
22 document.body.append(testDiv = new DivElement()); 23 document.body.append(testDiv = new DivElement());
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 {{ item }} 56 {{ item }}
56 </template> 57 </template>
57 </template>''')); 58 </template>'''));
58 query('#test') 59 query('#test')
59 ..bindingDelegate = new PolymerExpressions(globals: {'items': null}) 60 ..bindingDelegate = new PolymerExpressions(globals: {'items': null})
60 ..model = null; 61 ..model = null;
61 // the template should be the only node 62 // the template should be the only node
62 expect(testDiv.nodes.length, 1); 63 expect(testDiv.nodes.length, 1);
63 expect(testDiv.nodes[0].id, 'test'); 64 expect(testDiv.nodes[0].id, 'test');
64 }); 65 });
66
67 test('should silently handle bad variable names', () {
68 var logFuture = Logger.root.onRecord.toList();
Jennifer Messerly 2013/09/18 18:52:27 hmmm, I think this should be scoped to polymer_exp
69 testDiv.nodes.add(new Element.html('''
70 <template id="test" bind>{{ foo }}</template>'''));
71 query('#test')
72 ..bindingDelegate = new PolymerExpressions()
73 ..model = null;
Jennifer Messerly 2013/09/18 18:52:27 fyi -- I don't think setting model to null is requ
justinfagnani 2013/09/18 21:56:29 Done.
74 return new Future(() => null).then((_) {
Jennifer Messerly 2013/09/18 18:52:27 confused by `new Future(() => null).then((_) {` ..
justinfagnani 2013/09/18 21:56:29 Done.
75 Logger.root.clearListeners();
76 return logFuture.then((records) {
77 expect(records.length, 1);
78 expect(records.first.message, contains('Error evaluating expression')) ;
Jennifer Messerly 2013/09/18 18:52:27 long line. records[0].message? :)
justinfagnani 2013/09/18 21:56:29 Done.
79 expect(records.first.message, contains('foo'));
80 });
81 });
82 });
65 }); 83 });
66 } 84 }
67 85
68 class Person extends Object with ChangeNotifierMixin { 86 class Person extends Object with ChangeNotifierMixin {
69 static const _FIRST_NAME = const Symbol('firstName'); 87 static const _FIRST_NAME = const Symbol('firstName');
70 static const _LAST_NAME = const Symbol('lastName'); 88 static const _LAST_NAME = const Symbol('lastName');
71 static const _ITEMS = const Symbol('items'); 89 static const _ITEMS = const Symbol('items');
72 static const _GET_FULL_NAME = const Symbol('getFullName'); 90 static const _GET_FULL_NAME = const Symbol('getFullName');
73 91
74 String _firstName; 92 String _firstName;
(...skipping 21 matching lines...) Expand all
96 List<String> get items => _items; 114 List<String> get items => _items;
97 115
98 void set items(List<String> value) { 116 void set items(List<String> value) {
99 _items = value; 117 _items = value;
100 notifyChange(new PropertyChangeRecord(_ITEMS)); 118 notifyChange(new PropertyChangeRecord(_ITEMS));
101 } 119 }
102 120
103 String toString() => "Person(firstName: $_firstName, lastName: $_lastName)"; 121 String toString() => "Person(firstName: $_firstName, lastName: $_lastName)";
104 122
105 } 123 }
OLDNEW
« pkg/polymer_expressions/example/example.dart ('K') | « pkg/polymer_expressions/test/eval_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698