| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | |
| 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 #library('WindowNSMETest'); | |
| 6 #import('../../../../lib/unittest/unittest.dart'); | |
| 7 #import('../../../../lib/unittest/dom_config.dart'); | |
| 8 #import('dart:dom', prefix: 'dom'); | |
| 9 | |
| 10 // Not defined in dom.Window. | |
| 11 foo(x) => x; | |
| 12 | |
| 13 class Unused { | |
| 14 foo(x) => 'not $x'; | |
| 15 } | |
| 16 | |
| 17 int inscrutable(int x) => x == 0 ? 0 : x | inscrutable(x & (x - 1)); | |
| 18 | |
| 19 main() { | |
| 20 useDomConfiguration(); | |
| 21 var things = [new Unused(), dom.window]; | |
| 22 | |
| 23 test('windowNonMethod', () { | |
| 24 var win = things[inscrutable(1)]; | |
| 25 final message = foo("Hello World"); | |
| 26 try { | |
| 27 String x = win.foo(message); | |
| 28 Expect.fail('Should not reach here: $x'); | |
| 29 } catch (NoSuchMethodException e) { | |
| 30 // Expected exception. | |
| 31 } catch (Exception e) { | |
| 32 Expect.fail('Wrong exception: $e'); | |
| 33 } | |
| 34 }); | |
| 35 | |
| 36 test('foo', () { | |
| 37 var win = things[inscrutable(0)]; | |
| 38 String x = win.foo('bar'); | |
| 39 Expect.equals('not bar', x); | |
| 40 }); | |
| 41 | |
| 42 // Use dom.window direclty in case the compiler does type inference. | |
| 43 test('windowNonMethod2', () { | |
| 44 final message = foo("Hello World"); | |
| 45 try { | |
| 46 String x = dom.window.foo(message); | |
| 47 Expect.fail('Should not reach here: $x'); | |
| 48 } catch (NoSuchMethodException e) { | |
| 49 // Expected exception. | |
| 50 } catch (Exception e) { | |
| 51 Expect.fail('Wrong exception: $e'); | |
| 52 } | |
| 53 }); | |
| 54 } | |
| OLD | NEW |