Chromium Code Reviews| 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..ea163749417d407da984a4d326fd1c680ebf724e |
| --- /dev/null |
| +++ b/tests/compiler/dart2js_extra/interceptor_named_arguments_test.dart |
| @@ -0,0 +1,56 @@ |
| +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
|
karlklose
2015/07/10 12:23:34
2013 -> 2015.
herhut
2015/07/10 12:32:32
Acknowledged.
|
| +// 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); |
| +} |