OLD | NEW |
---|---|
(Empty) | |
1 // 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.
| |
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. | |
4 | |
5 | |
6 // Test that the proper one-shot interceptor is used for different | |
7 // combinations of named arguments. | |
8 import "package:expect/expect.dart"; | |
9 | |
10 // Use dart:html to get interceptors into play. | |
11 import "dart:html"; | |
12 | |
13 // [createFragment] has the same signature as in [Element]. | |
14 class Other { | |
15 createFragment(html, {validator, treeSanitizer}) { | |
16 int result = 0; | |
17 result += validator == null ? 0 : 2; | |
18 result += treeSanitizer == null ? 0 : 1; | |
19 return result; | |
20 } | |
21 } | |
22 | |
23 @NoInline() | |
24 bool wontTell(bool x) => x; | |
25 | |
26 | |
27 // Ensure that we use the interceptor only once per context so that we | |
28 // actually get a one-shot interceptor. This is a little brittle... | |
29 @NoInline() | |
30 testA(thing) { | |
31 Expect.equals(0, thing.createFragment(null)); | |
32 } | |
33 | |
34 @NoInline() | |
35 testB(thing) { | |
36 Expect.equals(2, thing.createFragment(null, validator: 1)); | |
37 } | |
38 | |
39 @NoInline() | |
40 testC(thing) { | |
41 Expect.equals(1, thing.createFragment(null, treeSanitizer: 1)); | |
42 } | |
43 | |
44 @NoInline() | |
45 testD(thing) { | |
46 Expect.equals(3, thing.createFragment(null, validator: 1, treeSanitizer: 1)); | |
47 } | |
48 | |
49 main () { | |
50 // Ensure we get interceptors into play. | |
51 var thing = wontTell(true) ? new Other() : new DivElement(); | |
52 testA(thing); | |
53 testB(thing); | |
54 testC(thing); | |
55 testD(thing); | |
56 } | |
OLD | NEW |