OLD | NEW |
(Empty) | |
| 1 dart_library.library('corelib/iterable_length_test', null, /* Imports */[ |
| 2 'dart_sdk', |
| 3 'expect' |
| 4 ], function load__iterable_length_test(exports, dart_sdk, expect) { |
| 5 'use strict'; |
| 6 const core = dart_sdk.core; |
| 7 const collection = dart_sdk.collection; |
| 8 const dart = dart_sdk.dart; |
| 9 const dartx = dart_sdk.dartx; |
| 10 const expect$ = expect.expect; |
| 11 const iterable_length_test = Object.create(null); |
| 12 let dynamicTodynamic = () => (dynamicTodynamic = dart.constFn(dart.definiteFun
ctionType(dart.dynamic, [dart.dynamic])))(); |
| 13 let dynamicTobool = () => (dynamicTobool = dart.constFn(dart.definiteFunctionT
ype(core.bool, [dart.dynamic])))(); |
| 14 let VoidTodynamic = () => (VoidTodynamic = dart.constFn(dart.definiteFunctionT
ype(dart.dynamic, [])))(); |
| 15 iterable_length_test.A = class A extends collection.IterableBase { |
| 16 new(count) { |
| 17 this.count = count; |
| 18 super.new(); |
| 19 } |
| 20 get iterator() { |
| 21 return new iterable_length_test.AIterator(this.count); |
| 22 } |
| 23 }; |
| 24 dart.addSimpleTypeTests(iterable_length_test.A); |
| 25 dart.setSignature(iterable_length_test.A, { |
| 26 constructors: () => ({new: dart.definiteFunctionType(iterable_length_test.A,
[core.int])}) |
| 27 }); |
| 28 dart.defineExtensionMembers(iterable_length_test.A, ['iterator']); |
| 29 const _count = Symbol('_count'); |
| 30 const _current = Symbol('_current'); |
| 31 iterable_length_test.AIterator = class AIterator extends core.Object { |
| 32 new(count) { |
| 33 this[_count] = count; |
| 34 this[_current] = null; |
| 35 } |
| 36 moveNext() { |
| 37 if (dart.notNull(this[_count]) > 0) { |
| 38 this[_current] = this[_count]; |
| 39 this[_count] = dart.notNull(this[_count]) - 1; |
| 40 return true; |
| 41 } |
| 42 this[_current] = null; |
| 43 return false; |
| 44 } |
| 45 get current() { |
| 46 return this[_current]; |
| 47 } |
| 48 }; |
| 49 iterable_length_test.AIterator[dart.implements] = () => [core.Iterator]; |
| 50 dart.setSignature(iterable_length_test.AIterator, { |
| 51 constructors: () => ({new: dart.definiteFunctionType(iterable_length_test.AI
terator, [core.int])}), |
| 52 methods: () => ({moveNext: dart.definiteFunctionType(core.bool, [])}) |
| 53 }); |
| 54 iterable_length_test.main = function() { |
| 55 let a = new iterable_length_test.A(10); |
| 56 expect$.Expect.equals(10, a.length); |
| 57 a = new iterable_length_test.A(0); |
| 58 expect$.Expect.equals(0, a.length); |
| 59 a = new iterable_length_test.A(5); |
| 60 expect$.Expect.equals(5, a.map(dart.dynamic)(dart.fn(e => dart.dsend(e, '+',
1), dynamicTodynamic()))[dartx.length]); |
| 61 expect$.Expect.equals(3, a.where(dart.fn(e => core.bool._check(dart.dsend(e,
'>=', 3)), dynamicTobool()))[dartx.length]); |
| 62 }; |
| 63 dart.fn(iterable_length_test.main, VoidTodynamic()); |
| 64 // Exports: |
| 65 exports.iterable_length_test = iterable_length_test; |
| 66 }); |
OLD | NEW |