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

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
« no previous file with comments | « pkg/polymer_expressions/test/eval_test.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 25 matching lines...) Expand all
48 }); 49 });
49 }); 50 });
50 51
51 test('should handle null collections in "in" expressions', () { 52 test('should handle null collections in "in" expressions', () {
52 testDiv.nodes.add(new Element.html(''' 53 testDiv.nodes.add(new Element.html('''
53 <template id="test" bind> 54 <template id="test" bind>
54 <template repeat="{{ item in items }}"> 55 <template repeat="{{ item in items }}">
55 {{ item }} 56 {{ item }}
56 </template> 57 </template>
57 </template>''')); 58 </template>'''));
58 query('#test') 59 query('#test').bindingDelegate =
59 ..bindingDelegate = new PolymerExpressions(globals: {'items': null}) 60 new PolymerExpressions(globals: {'items': null});
60 ..model = null;
61 // the template should be the only node 61 // the template should be the only node
62 expect(testDiv.nodes.length, 1); 62 expect(testDiv.nodes.length, 1);
63 expect(testDiv.nodes[0].id, 'test'); 63 expect(testDiv.nodes[0].id, 'test');
64 }); 64 });
65
66 test('should silently handle bad variable names', () {
67 var logger = new Logger('polymer_expressions');
68 var logFuture = logger.onRecord.toList();
69 testDiv.nodes.add(new Element.html('''
70 <template id="test" bind>{{ foo }}</template>'''));
71 query('#test').bindingDelegate = new PolymerExpressions();
72 return new Future(() {
73 logger.clearListeners();
74 return logFuture.then((records) {
75 expect(records.length, 1);
76 expect(records.first.message,
77 contains('Error evaluating expression'));
78 expect(records.first.message, contains('foo'));
79 });
80 });
81 });
65 }); 82 });
66 } 83 }
67 84
68 class Person extends Object with ChangeNotifierMixin { 85 class Person extends Object with ChangeNotifierMixin {
69 static const _FIRST_NAME = const Symbol('firstName'); 86 static const _FIRST_NAME = const Symbol('firstName');
70 static const _LAST_NAME = const Symbol('lastName'); 87 static const _LAST_NAME = const Symbol('lastName');
71 static const _ITEMS = const Symbol('items'); 88 static const _ITEMS = const Symbol('items');
72 static const _GET_FULL_NAME = const Symbol('getFullName'); 89 static const _GET_FULL_NAME = const Symbol('getFullName');
73 90
74 String _firstName; 91 String _firstName;
(...skipping 21 matching lines...) Expand all
96 List<String> get items => _items; 113 List<String> get items => _items;
97 114
98 void set items(List<String> value) { 115 void set items(List<String> value) {
99 _items = value; 116 _items = value;
100 notifyChange(new PropertyChangeRecord(_ITEMS)); 117 notifyChange(new PropertyChangeRecord(_ITEMS));
101 } 118 }
102 119
103 String toString() => "Person(firstName: $_firstName, lastName: $_lastName)"; 120 String toString() => "Person(firstName: $_firstName, lastName: $_lastName)";
104 121
105 } 122 }
OLDNEW
« no previous file with comments | « 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