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

Unified Diff: third_party/pkg/angular/test/core/parser/parser_spec.dart

Issue 148453003: Updating Angular version (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: third_party/pkg/angular/test/core/parser/parser_spec.dart
diff --git a/third_party/pkg/angular/test/core/parser/parser_spec.dart b/third_party/pkg/angular/test/core/parser/parser_spec.dart
index 798145ecb41fe6327a74b6e4681d88816c18626b..6578931c3e39b5e6521cd024b953c0a177774ce8 100644
--- a/third_party/pkg/angular/test/core/parser/parser_spec.dart
+++ b/third_party/pkg/angular/test/core/parser/parser_spec.dart
@@ -35,11 +35,17 @@ class InheritedMapData extends MapData {
noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
}
+class WithPrivateField {
+ int publicField = 4;
+ int _privateField = 5;
+}
+
toBool(x) => (x is num) ? x != 0 : x == true;
main() {
describe('parse', () {
- var scope, parser;
+ var scope;
+ Parser<Expression> parser;
beforeEach(module((Module module) {
module.type(IncrementFilter);
module.type(SubstringFilter);
@@ -136,7 +142,7 @@ main() {
});
describe('error handling', () {
- var parser;
+ Parser<Expression> parser;
beforeEach(inject((Parser p) {
parser = p;
@@ -171,46 +177,92 @@ main() {
});
- it('should throw on undefined functions', () {
- expectEval("notAFn()").toThrow(errStr('Eval Error: Undefined function notAFn while evaling [notAFn()]'));
+ it('should throw on incorrect ternary operator syntax', () {
+ expectEval("true?1").toThrow('Parser Error: Conditional expression true?1 requires all 3 expressions');
});
- it('should throw on not-function function calls', () {
- expectEval("4()").toThrow(errStr('Eval Error: 4 is not a function while evaling [4()]'));
+ it('should throw on non-function function calls', () {
+ expectEval("4()").toThrow('4 is not a function');
});
- it('should throw on incorrect ternary operator syntax', () {
- expectEval("true?1").toThrow(errStr(
- 'Conditional expression true?1 requires all 3 expressions'));
+ it('should fail gracefully when invoking non-function', () {
+ expect(() {
+ parser('a[0]()').eval({'a': [4]});
+ }).toThrow('a[0] is not a function');
+
+ expect(() {
+ parser('a[x()]()').eval({'a': [4], 'x': () => 0});
+ }).toThrow('a[x()] is not a function');
+
+ expect(() {
+ parser('{}()').eval({});
+ }).toThrow('{} is not a function');
});
- it('should fail gracefully when missing a function', () {
+ it('should throw on undefined functions (relaxed message)', () {
+ expectEval("notAFn()").toThrow('notAFn');
+ });
+
+
+ it('should fail gracefully when missing a function (relaxed message)', () {
expect(() {
parser('doesNotExist()').eval({});
- }).toThrow('Undefined function doesNotExist');
+ }).toThrow('doesNotExist');
expect(() {
parser('exists(doesNotExist())').eval({'exists': () => true});
- }).toThrow('Undefined function doesNotExist');
+ }).toThrow('doesNotExist');
expect(() {
parser('doesNotExists(exists())').eval({'exists': () => true});
- }).toThrow('Undefined function doesNotExist');
+ }).toThrow('doesNotExist');
expect(() {
- parser('a[0]()').eval({'a': [4]});
- }).toThrow('a[0] is not a function');
+ parser('doesNotExist(1)').eval({});
+ }).toThrow('doesNotExist');
expect(() {
- parser('a[x()]()').eval({'a': [4], 'x': () => 0});
- }).toThrow('a[x()] is not a function');
+ parser('doesNotExist(1, 2)').eval({});
+ }).toThrow('doesNotExist');
expect(() {
- parser('{}()').eval({});
- }).toThrow('{} is not a function');
+ parser('doesNotExist()').eval(new TestData());
+ }).toThrow('doesNotExist');
+
+ expect(() {
+ parser('doesNotExist(1)').eval(new TestData());
+ }).toThrow('doesNotExist');
+
+ expect(() {
+ parser('doesNotExist(1, 2)').eval(new TestData());
+ }).toThrow('doesNotExist');
+
+ expect(() {
+ parser('a.doesNotExist()').eval({'a': {}});
+ }).toThrow('doesNotExist');
+
+ expect(() {
+ parser('a.doesNotExist(1)').eval({'a': {}});
+ }).toThrow('doesNotExist');
+
+ expect(() {
+ parser('a.doesNotExist(1, 2)').eval({'a': {}});
+ }).toThrow('doesNotExist');
+
+ expect(() {
+ parser('a.doesNotExist()').eval({'a': new TestData()});
+ }).toThrow('doesNotExist');
+
+ expect(() {
+ parser('a.doesNotExist(1)').eval({'a': new TestData()});
+ }).toThrow('doesNotExist');
+
+ expect(() {
+ parser('a.doesNotExist(1, 2)').eval({'a': new TestData()});
+ }).toThrow('doesNotExist');
});
@@ -218,7 +270,7 @@ main() {
scope['map'] = {};
expect(eval('null')).toBe(null);
- //expect(eval('map.null')).toBe(null);
+ expect(eval('map.null')).toBe(null);
});
@@ -246,6 +298,16 @@ main() {
parser('notAProperty').eval(new TestData());
}).toThrow("notAProperty");
});
+
+ it('should fail on private field access', () {
+ expect(parser('publicField').eval(new WithPrivateField())).toEqual(4);
+ // On Dartium, this fails with "NoSuchMethod: no instance getter"
+ // On dart2js with generated functions: NoSuchMethod: method not found
+ // On dart2js with reflection: ArgumentError: private identifier"
+ expect(() {
+ parser('_privateField').eval(new WithPrivateField());
+ }).toThrow();
+ });
});
describe('setters', () {

Powered by Google App Engine
This is Rietveld 408576698