OLD | NEW |
(Empty) | |
| 1 dart_library.library('language/null_access_error_test', null, /* Imports */[ |
| 2 'dart_sdk', |
| 3 'expect' |
| 4 ], function load__null_access_error_test(exports, dart_sdk, expect) { |
| 5 'use strict'; |
| 6 const core = dart_sdk.core; |
| 7 const dart = dart_sdk.dart; |
| 8 const dartx = dart_sdk.dartx; |
| 9 const expect$ = expect.expect; |
| 10 const null_access_error_test = Object.create(null); |
| 11 let VoidTodynamic = () => (VoidTodynamic = dart.constFn(dart.definiteFunctionT
ype(dart.dynamic, [])))(); |
| 12 null_access_error_test.NullAccessTest = class NullAccessTest extends core.Obje
ct { |
| 13 static testNullVariable() { |
| 14 let variable = null; |
| 15 let exceptionCaught = false; |
| 16 let wrongExceptionCaught = false; |
| 17 try { |
| 18 variable = dart.notNull(variable) + 1; |
| 19 } catch (e) { |
| 20 if (core.NoSuchMethodError.is(e)) { |
| 21 let ex = e; |
| 22 exceptionCaught = true; |
| 23 } else { |
| 24 let ex = e; |
| 25 wrongExceptionCaught = true; |
| 26 } |
| 27 } |
| 28 |
| 29 expect$.Expect.isTrue(exceptionCaught); |
| 30 expect$.Expect.isFalse(wrongExceptionCaught); |
| 31 } |
| 32 static helperFunction(parameter) { |
| 33 let x = parameter; |
| 34 parameter = dart.notNull(x) + 1; |
| 35 return x; |
| 36 } |
| 37 static testNullFunctionCall() { |
| 38 let variable = null; |
| 39 let exceptionCaught = false; |
| 40 let wrongExceptionCaught = false; |
| 41 try { |
| 42 variable = null_access_error_test.NullAccessTest.helperFunction(variable
); |
| 43 } catch (e) { |
| 44 if (core.NoSuchMethodError.is(e)) { |
| 45 let ex = e; |
| 46 exceptionCaught = true; |
| 47 } else { |
| 48 let ex = e; |
| 49 wrongExceptionCaught = true; |
| 50 } |
| 51 } |
| 52 |
| 53 expect$.Expect.isTrue(exceptionCaught); |
| 54 expect$.Expect.isFalse(wrongExceptionCaught); |
| 55 } |
| 56 static testMain() { |
| 57 null_access_error_test.NullAccessTest.testNullVariable(); |
| 58 null_access_error_test.NullAccessTest.testNullFunctionCall(); |
| 59 } |
| 60 }; |
| 61 dart.setSignature(null_access_error_test.NullAccessTest, { |
| 62 statics: () => ({ |
| 63 testNullVariable: dart.definiteFunctionType(dart.void, []), |
| 64 helperFunction: dart.definiteFunctionType(core.int, [core.int]), |
| 65 testNullFunctionCall: dart.definiteFunctionType(dart.void, []), |
| 66 testMain: dart.definiteFunctionType(dart.void, []) |
| 67 }), |
| 68 names: ['testNullVariable', 'helperFunction', 'testNullFunctionCall', 'testM
ain'] |
| 69 }); |
| 70 null_access_error_test.main = function() { |
| 71 null_access_error_test.NullAccessTest.testMain(); |
| 72 }; |
| 73 dart.fn(null_access_error_test.main, VoidTodynamic()); |
| 74 // Exports: |
| 75 exports.null_access_error_test = null_access_error_test; |
| 76 }); |
OLD | NEW |