OLD | NEW |
(Empty) | |
| 1 dart_library.library('corelib/stacktrace_fromstring_test', null, /* Imports */[ |
| 2 'dart_sdk', |
| 3 'expect', |
| 4 'async_helper' |
| 5 ], function load__stacktrace_fromstring_test(exports, dart_sdk, expect, async_he
lper) { |
| 6 'use strict'; |
| 7 const core = dart_sdk.core; |
| 8 const async = dart_sdk.async; |
| 9 const dart = dart_sdk.dart; |
| 10 const dartx = dart_sdk.dartx; |
| 11 const expect$ = expect.expect; |
| 12 const async_helper$ = async_helper.async_helper; |
| 13 const stacktrace_fromstring_test = Object.create(null); |
| 14 let dynamicTovoid = () => (dynamicTovoid = dart.constFn(dart.definiteFunctionT
ype(dart.void, [dart.dynamic])))(); |
| 15 let dynamicAnddynamicTodynamic = () => (dynamicAnddynamicTodynamic = dart.cons
tFn(dart.definiteFunctionType(dart.dynamic, [dart.dynamic, dart.dynamic])))(); |
| 16 let dynamicTodynamic = () => (dynamicTodynamic = dart.constFn(dart.definiteFun
ctionType(dart.dynamic, [dart.dynamic])))(); |
| 17 let VoidTovoid = () => (VoidTovoid = dart.constFn(dart.definiteFunctionType(da
rt.void, [])))(); |
| 18 stacktrace_fromstring_test.main = function() { |
| 19 let stack = null; |
| 20 try { |
| 21 dart.throw(0); |
| 22 } catch (e) { |
| 23 let s = dart.stackTrace(e); |
| 24 stack = s; |
| 25 } |
| 26 |
| 27 let string = dart.str`${stack}`; |
| 28 let stringTrace = core.StackTrace.fromString(string); |
| 29 expect$.Expect.isTrue(core.StackTrace.is(stringTrace)); |
| 30 expect$.Expect.equals(dart.toString(stack), stringTrace.toString()); |
| 31 string = "some random string, nothing like a StackTrace"; |
| 32 stringTrace = core.StackTrace.fromString(string); |
| 33 expect$.Expect.isTrue(core.StackTrace.is(stringTrace)); |
| 34 expect$.Expect.equals(string, stringTrace.toString()); |
| 35 async_helper$.asyncStart(); |
| 36 let c = async.Completer.new(); |
| 37 c.completeError(0, stringTrace); |
| 38 c.future.then(dart.dynamic)(dart.fn(v => { |
| 39 dart.throw(dart.str`Unexpected value: ${v}`); |
| 40 }, dynamicTodynamic()), {onError: dart.fn((e, s) => { |
| 41 expect$.Expect.equals(string, dart.toString(s)); |
| 42 }, dynamicAnddynamicTodynamic())}).then(dart.dynamic)(dart.fn(_ => { |
| 43 let c = async.StreamController.new(); |
| 44 c.stream.listen(dart.fn(v => { |
| 45 dart.throw(dart.str`Unexpected value: ${v}`); |
| 46 }, dynamicTovoid()), {onError: dart.fn((e, s) => { |
| 47 expect$.Expect.equals(string, dart.toString(s)); |
| 48 async_helper$.asyncEnd(); |
| 49 }, dynamicAnddynamicTodynamic())}); |
| 50 c.addError(0, stringTrace); |
| 51 c.close(); |
| 52 }, dynamicTodynamic())); |
| 53 }; |
| 54 dart.fn(stacktrace_fromstring_test.main, VoidTovoid()); |
| 55 // Exports: |
| 56 exports.stacktrace_fromstring_test = stacktrace_fromstring_test; |
| 57 }); |
OLD | NEW |