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

Unified Diff: tests/language_strong/invocation_mirror_test.dart

Issue 2771453003: Format all tests. (Closed)
Patch Set: Format files Created 3 years, 8 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: tests/language_strong/invocation_mirror_test.dart
diff --git a/tests/language_strong/invocation_mirror_test.dart b/tests/language_strong/invocation_mirror_test.dart
index 6ea715d5e8f6c1f714492603af12764fe62a0f11..6eca589446815e593a5a866040f6f4a37037e58e 100644
--- a/tests/language_strong/invocation_mirror_test.dart
+++ b/tests/language_strong/invocation_mirror_test.dart
@@ -17,7 +17,6 @@ Map<Symbol, dynamic> listToNamedArguments(list) {
return result;
}
-
/** Class with noSuchMethod that returns the mirror */
class N {
// Storage for the last argument to noSuchMethod.
@@ -25,18 +24,31 @@ class N {
var last;
noSuchMethod(Invocation m) => last = m;
- flif(int x) { Expect.fail("never get here"); }
- flaf([int x]) { Expect.fail("never get here"); }
- flof({int y}) { Expect.fail("never get here"); }
+ flif(int x) {
+ Expect.fail("never get here");
+ }
+
+ flaf([int x]) {
+ Expect.fail("never get here");
+ }
+
+ flof({int y}) {
+ Expect.fail("never get here");
+ }
get wut => this;
final int plif = 99;
- int get plaf { Expect.fail("never get here"); return 0; }
+ int get plaf {
+ Expect.fail("never get here");
+ return 0;
+ }
}
/** As [N] but also implements 'call', so we can call it with wrong arguments.*/
class C extends N {
- call(int x) { Expect.fail("never get here"); }
+ call(int x) {
+ Expect.fail("never get here");
+ }
}
/**
@@ -46,7 +58,7 @@ class C extends N {
* and with both optionals for everything else.
*/
testInvocationMirror(Invocation im, Symbol name,
- [List positional, List named]) {
+ [List positional, List named]) {
Expect.isTrue(im is Invocation, "is Invocation");
Expect.equals(name, im.memberName, "name");
if (named == null) {
@@ -62,8 +74,8 @@ testInvocationMirror(Invocation im, Symbol name,
Expect.isTrue(im.isSetter, "$name:isSetter");
Expect.isFalse(im.isGetter, "$name:isGetter");
Expect.equals(1, im.positionalArguments.length, "$name:#positional");
- Expect.equals(positional[0], im.positionalArguments[0],
- "$name:positional[0]");
+ Expect.equals(
+ positional[0], im.positionalArguments[0], "$name:positional[0]");
Expect.equals(0, im.namedArguments.length, "$name:#named");
return;
}
@@ -75,16 +87,15 @@ testInvocationMirror(Invocation im, Symbol name,
Expect.listEquals(positional, im.positionalArguments);
- Expect.equals(namedArguments.length, im.namedArguments.length,
- "$name:#named");
+ Expect.equals(
+ namedArguments.length, im.namedArguments.length, "$name:#named");
namedArguments.forEach((k, v) {
- Expect.isTrue(im.namedArguments.containsKey(k),
- "$name:?namedArguments[$k]");
+ Expect.isTrue(
+ im.namedArguments.containsKey(k), "$name:?namedArguments[$k]");
Expect.equals(v, im.namedArguments[k], "$name:namedArguments[$k]");
});
}
-
// Test different ways that noSuchMethod can be called.
testInvocationMirrors() {
var n = new N();
@@ -95,10 +106,10 @@ testInvocationMirrors() {
testInvocationMirror((n..bar = 42).last, const Symbol('bar='), [42]);
testInvocationMirror(n.bar(), const Symbol('bar'), [], []);
testInvocationMirror(n.bar(42), const Symbol('bar'), [42], []);
- testInvocationMirror(n.bar(x: 42), const Symbol('bar'), [],
- [const Symbol("x"), 42]);
- testInvocationMirror(n.bar(37, x: 42), const Symbol('bar'), [37],
- [const Symbol("x"), 42]);
+ testInvocationMirror(
+ n.bar(x: 42), const Symbol('bar'), [], [const Symbol("x"), 42]);
+ testInvocationMirror(
+ n.bar(37, x: 42), const Symbol('bar'), [37], [const Symbol("x"), 42]);
// Missing operator access.
testInvocationMirror(n + 4, const Symbol('+'), [4], []);
@@ -110,40 +121,40 @@ testInvocationMirrors() {
// Calling as function when it's not.
testInvocationMirror(n(), const Symbol('call'), [], []);
testInvocationMirror(n(42), const Symbol('call'), [42], []);
- testInvocationMirror(n(x: 42), const Symbol('call'), [],
- [const Symbol("x"), 42]);
- testInvocationMirror(n(37, x: 42), const Symbol('call'), [37],
- [const Symbol("x"), 42]);
+ testInvocationMirror(
+ n(x: 42), const Symbol('call'), [], [const Symbol("x"), 42]);
+ testInvocationMirror(
+ n(37, x: 42), const Symbol('call'), [37], [const Symbol("x"), 42]);
// Calling with arguments not matching existing call method.
testInvocationMirror(c(), const Symbol('call'), [], []);
testInvocationMirror(c(37, 42), const Symbol('call'), [37, 42], []);
- testInvocationMirror(c(x: 42), const Symbol('call'), [],
- [const Symbol("x"), 42]);
- testInvocationMirror(c(37, x: 42), const Symbol('call'), [37],
- [const Symbol("x"), 42]);
+ testInvocationMirror(
+ c(x: 42), const Symbol('call'), [], [const Symbol("x"), 42]);
+ testInvocationMirror(
+ c(37, x: 42), const Symbol('call'), [37], [const Symbol("x"), 42]);
// Wrong arguments to existing function.
testInvocationMirror(n.flif(), const Symbol("flif"), [], []);
testInvocationMirror(n.flif(37, 42), const Symbol("flif"), [37, 42], []);
- testInvocationMirror(n.flif(x: 42), const Symbol("flif"), [],
- [const Symbol("x"), 42]);
- testInvocationMirror(n.flif(37, x: 42), const Symbol("flif"), [37],
- [const Symbol("x"), 42]);
+ testInvocationMirror(
+ n.flif(x: 42), const Symbol("flif"), [], [const Symbol("x"), 42]);
+ testInvocationMirror(
+ n.flif(37, x: 42), const Symbol("flif"), [37], [const Symbol("x"), 42]);
testInvocationMirror((n..flif = 42).last, const Symbol("flif="), [42]);
testInvocationMirror(n.flaf(37, 42), const Symbol("flaf"), [37, 42], []);
- testInvocationMirror(n.flaf(x: 42), const Symbol("flaf"), [],
- [const Symbol("x"), 42]);
- testInvocationMirror(n.flaf(37, x: 42), const Symbol("flaf"), [37],
- [const Symbol("x"), 42]);
+ testInvocationMirror(
+ n.flaf(x: 42), const Symbol("flaf"), [], [const Symbol("x"), 42]);
+ testInvocationMirror(
+ n.flaf(37, x: 42), const Symbol("flaf"), [37], [const Symbol("x"), 42]);
testInvocationMirror((n..flaf = 42).last, const Symbol("flaf="), [42]);
testInvocationMirror(n.flof(37, 42), const Symbol("flof"), [37, 42], []);
- testInvocationMirror(n.flof(x: 42), const Symbol("flof"), [],
- [const Symbol("x"), 42]);
- testInvocationMirror(n.flof(37, y: 42), const Symbol("flof"), [37],
- [const Symbol("y"), 42]);
+ testInvocationMirror(
+ n.flof(x: 42), const Symbol("flof"), [], [const Symbol("x"), 42]);
+ testInvocationMirror(
+ n.flof(37, y: 42), const Symbol("flof"), [37], [const Symbol("y"), 42]);
testInvocationMirror((n..flof = 42).last, const Symbol("flof="), [42]);
// Reading works.
@@ -161,74 +172,89 @@ testInvocationMirrors() {
// Calling noSuchMethod itself, badly.
testInvocationMirror(n.noSuchMethod(), const Symbol("noSuchMethod"), [], []);
- testInvocationMirror(n.noSuchMethod(37, 42), const Symbol("noSuchMethod"),
- [37, 42], []);
- testInvocationMirror(n.noSuchMethod(37, x:42),
- const Symbol("noSuchMethod"), [37],
- [const Symbol("x"), 42]);
- testInvocationMirror(n.noSuchMethod(x:42), const Symbol("noSuchMethod"), [],
- [const Symbol("x"), 42]);
+ testInvocationMirror(
+ n.noSuchMethod(37, 42), const Symbol("noSuchMethod"), [37, 42], []);
+ testInvocationMirror(n.noSuchMethod(37, x: 42), const Symbol("noSuchMethod"),
+ [37], [const Symbol("x"), 42]);
+ testInvocationMirror(n.noSuchMethod(x: 42), const Symbol("noSuchMethod"), [],
+ [const Symbol("x"), 42]);
// Closurizing a method means that calling it badly will not hit the
// original receivers noSuchMethod, only the one inherited from Object
// by the closure object.
- Expect.throws(() { var x = n.flif; x(37, 42); },
- (e) => e is NoSuchMethodError);
- Expect.throws(() { var x = c.call; x(37, 42); },
- (e) => e is NoSuchMethodError);
+ Expect.throws(() {
+ var x = n.flif;
+ x(37, 42);
+ }, (e) => e is NoSuchMethodError);
+ Expect.throws(() {
+ var x = c.call;
+ x(37, 42);
+ }, (e) => e is NoSuchMethodError);
}
class M extends N {
- noSuchMethod(Invocation m) { throw "never get here"; }
+ noSuchMethod(Invocation m) {
+ throw "never get here";
+ }
testSuperCalls() {
// Missing property/method access.
testInvocationMirror(super.bar, const Symbol('bar'));
- testInvocationMirror((){super.bar = 42; return last;}(),
- const Symbol('bar='), [42]);
+ testInvocationMirror(() {
+ super.bar = 42;
+ return last;
+ }(), const Symbol('bar='), [42]);
testInvocationMirror(super.bar(), const Symbol('bar'), [], []);
testInvocationMirror(super.bar(42), const Symbol('bar'), [42], []);
- testInvocationMirror(super.bar(x: 42), const Symbol('bar'), [],
- [const Symbol("x"), 42]);
+ testInvocationMirror(
+ super.bar(x: 42), const Symbol('bar'), [], [const Symbol("x"), 42]);
testInvocationMirror(super.bar(37, x: 42), const Symbol('bar'), [37],
- [const Symbol("x"), 42]);
+ [const Symbol("x"), 42]);
// Missing operator access.
testInvocationMirror(super + 4, const Symbol('+'), [4], []);
testInvocationMirror(super - 4, const Symbol('-'), [4], []);
testInvocationMirror(-super, const Symbol('unary-'), [], []);
testInvocationMirror(super[42], const Symbol('[]'), [42], []);
- testInvocationMirror((){super[37] = 42; return last;}(),
- const Symbol('[]='), [37, 42], []);
+ testInvocationMirror(() {
+ super[37] = 42;
+ return last;
+ }(), const Symbol('[]='), [37, 42], []);
// Wrong arguments to existing function.
testInvocationMirror(super.flif(), const Symbol("flif"), [], []);
- testInvocationMirror(super.flif(37, 42), const Symbol("flif"), [37, 42],
- []);
- testInvocationMirror(super.flif(x: 42), const Symbol("flif"), [],
- [const Symbol("x"), 42]);
+ testInvocationMirror(
+ super.flif(37, 42), const Symbol("flif"), [37, 42], []);
+ testInvocationMirror(
+ super.flif(x: 42), const Symbol("flif"), [], [const Symbol("x"), 42]);
testInvocationMirror(super.flif(37, x: 42), const Symbol("flif"), [37],
- [const Symbol("x"), 42]);
- testInvocationMirror((){super.flif = 42; return last;}(),
- const Symbol("flif="), [42]);
-
- testInvocationMirror(super.flaf(37, 42), const Symbol("flaf"), [37, 42],
- []);
- testInvocationMirror(super.flaf(x: 42), const Symbol("flaf"), [],
- [const Symbol("x"), 42]);
+ [const Symbol("x"), 42]);
+ testInvocationMirror(() {
+ super.flif = 42;
+ return last;
+ }(), const Symbol("flif="), [42]);
+
+ testInvocationMirror(
+ super.flaf(37, 42), const Symbol("flaf"), [37, 42], []);
+ testInvocationMirror(
+ super.flaf(x: 42), const Symbol("flaf"), [], [const Symbol("x"), 42]);
testInvocationMirror(super.flaf(37, x: 42), const Symbol("flaf"), [37],
- [const Symbol("x"), 42]);
- testInvocationMirror((){super.flaf = 42; return last;}(),
- const Symbol("flaf="), [42]);
-
- testInvocationMirror(super.flof(37, 42), const Symbol("flof"), [37, 42],
- []);
- testInvocationMirror(super.flof(x: 42), const Symbol("flof"), [],
- [const Symbol("x"), 42]);
+ [const Symbol("x"), 42]);
+ testInvocationMirror(() {
+ super.flaf = 42;
+ return last;
+ }(), const Symbol("flaf="), [42]);
+
+ testInvocationMirror(
+ super.flof(37, 42), const Symbol("flof"), [37, 42], []);
+ testInvocationMirror(
+ super.flof(x: 42), const Symbol("flof"), [], [const Symbol("x"), 42]);
testInvocationMirror(super.flof(37, y: 42), const Symbol("flof"), [37],
- [const Symbol("y"), 42]);
- testInvocationMirror((){super.flof = 42; return last;}(),
- const Symbol("flof="), [42]);
+ [const Symbol("y"), 42]);
+ testInvocationMirror(() {
+ super.flof = 42;
+ return last;
+ }(), const Symbol("flof="), [42]);
// Reading works.
Expect.isTrue(super.flif is Function);
@@ -236,40 +262,45 @@ class M extends N {
Expect.isTrue(super.flof is Function);
// Writing to read-only fields.
- testInvocationMirror((){super.wut = 42; return last;}(),
- const Symbol("wut="), [42]);
- testInvocationMirror((){super.plif = 42; return last;}(),
- const Symbol("plif="), [42]);
- testInvocationMirror((){super.plaf = 42; return last;}(),
- const Symbol("plaf="), [42]);
+ testInvocationMirror(() {
+ super.wut = 42;
+ return last;
+ }(), const Symbol("wut="), [42]);
+ testInvocationMirror(() {
+ super.plif = 42;
+ return last;
+ }(), const Symbol("plif="), [42]);
+ testInvocationMirror(() {
+ super.plaf = 42;
+ return last;
+ }(), const Symbol("plaf="), [42]);
// Calling noSuchMethod itself, badly.
- testInvocationMirror(super.noSuchMethod(), const Symbol("noSuchMethod"), [],
- []);
- testInvocationMirror(super.noSuchMethod(37, 42),
- const Symbol("noSuchMethod"), [37, 42], []);
- testInvocationMirror(super.noSuchMethod(37, x:42),
- const Symbol("noSuchMethod"), [37],
- [const Symbol("x"), 42]);
- testInvocationMirror(super.noSuchMethod(x:42),
- const Symbol("noSuchMethod"), [],
- [const Symbol("x"), 42]);
+ testInvocationMirror(
+ super.noSuchMethod(), const Symbol("noSuchMethod"), [], []);
+ testInvocationMirror(
+ super.noSuchMethod(37, 42), const Symbol("noSuchMethod"), [37, 42], []);
+ testInvocationMirror(super.noSuchMethod(37, x: 42),
+ const Symbol("noSuchMethod"), [37], [const Symbol("x"), 42]);
+ testInvocationMirror(super.noSuchMethod(x: 42),
+ const Symbol("noSuchMethod"), [], [const Symbol("x"), 42]);
// Closurizing a method means that calling it badly will not hit the
// original receivers noSuchMethod, only the one inherited from Object
// by the closure object.
- Expect.throws(() { var x = super.flif; x(37, 42); },
- (e) => e is NoSuchMethodError);
+ Expect.throws(() {
+ var x = super.flif;
+ x(37, 42);
+ }, (e) => e is NoSuchMethodError);
}
}
-
-
// Test the NoSuchMethodError thrown by different incorrect calls.
testNoSuchMethodErrors() {
test(Function block) {
Expect.throws(block, (e) => e is NoSuchMethodError);
}
+
var n = new N();
var o = new Object();
test(() => o.bar);
@@ -284,8 +315,8 @@ testNoSuchMethodErrors() {
test(() => o.toString(42));
test(() => o.toString(x: 37));
test(() => o.hashCode = 42);
- test(() => o.hashCode()); // Thrown by int.noSuchMethod.
- test(() => (n.flif)()); // Extracted method has no noSuchMethod.
+ test(() => o.hashCode()); // Thrown by int.noSuchMethod.
+ test(() => (n.flif)()); // Extracted method has no noSuchMethod.
}
main() {

Powered by Google App Engine
This is Rietveld 408576698