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

Unified Diff: tests/compiler/dart2js_extra/interceptor_named_arguments_test.dart

Issue 1235463004: dart2js: Take named arguments into account (again) when naming one-shot interceptors. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: fix date Created 5 years, 5 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
« no previous file with comments | « pkg/compiler/lib/src/js_backend/minify_namer.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/compiler/dart2js_extra/interceptor_named_arguments_test.dart
diff --git a/tests/compiler/dart2js_extra/interceptor_named_arguments_test.dart b/tests/compiler/dart2js_extra/interceptor_named_arguments_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..6911a96c4480f3188616b181a856c399e9b65eb8
--- /dev/null
+++ b/tests/compiler/dart2js_extra/interceptor_named_arguments_test.dart
@@ -0,0 +1,56 @@
+// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+
+// Test that the proper one-shot interceptor is used for different
+// combinations of named arguments.
+import "package:expect/expect.dart";
+
+// Use dart:html to get interceptors into play.
+import "dart:html";
+
+// [createFragment] has the same signature as in [Element].
+class Other {
+ createFragment(html, {validator, treeSanitizer}) {
+ int result = 0;
+ result += validator == null ? 0 : 2;
+ result += treeSanitizer == null ? 0 : 1;
+ return result;
+ }
+}
+
+@NoInline()
+bool wontTell(bool x) => x;
+
+
+// Ensure that we use the interceptor only once per context so that we
+// actually get a one-shot interceptor. This is a little brittle...
+@NoInline()
+testA(thing) {
+ Expect.equals(0, thing.createFragment(null));
+}
+
+@NoInline()
+testB(thing) {
+ Expect.equals(2, thing.createFragment(null, validator: 1));
+}
+
+@NoInline()
+testC(thing) {
+ Expect.equals(1, thing.createFragment(null, treeSanitizer: 1));
+}
+
+@NoInline()
+testD(thing) {
+ Expect.equals(3, thing.createFragment(null, validator: 1, treeSanitizer: 1));
+}
+
+main () {
+ // Ensure we get interceptors into play.
+ var thing = wontTell(true) ? new Other() : new DivElement();
+ testA(thing);
+ testB(thing);
+ testC(thing);
+ testD(thing);
+}
« no previous file with comments | « pkg/compiler/lib/src/js_backend/minify_namer.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698