Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(182)

Unified Diff: test/codegen/expect/corelib/iterable_skip_test.js

Issue 2128353002: Check in codegen test expectations. (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: test/codegen/expect/corelib/iterable_skip_test.js
diff --git a/test/codegen/expect/corelib/iterable_skip_test.js b/test/codegen/expect/corelib/iterable_skip_test.js
new file mode 100644
index 0000000000000000000000000000000000000000..72154b5b4345f0b0334fb0b4b38a3c4e595d46f0
--- /dev/null
+++ b/test/codegen/expect/corelib/iterable_skip_test.js
@@ -0,0 +1,258 @@
+dart_library.library('corelib/iterable_skip_test', null, /* Imports */[
+ 'dart_sdk',
+ 'expect'
+], function load__iterable_skip_test(exports, dart_sdk, expect) {
+ 'use strict';
+ const core = dart_sdk.core;
+ const _interceptors = dart_sdk._interceptors;
+ const dart = dart_sdk.dart;
+ const dartx = dart_sdk.dartx;
+ const expect$ = expect.expect;
+ const iterable_skip_test = Object.create(null);
+ let JSArrayOfint = () => (JSArrayOfint = dart.constFn(_interceptors.JSArray$(core.int)))();
+ let JSArrayOfString = () => (JSArrayOfString = dart.constFn(_interceptors.JSArray$(core.String)))();
+ let SetOfint = () => (SetOfint = dart.constFn(core.Set$(core.int)))();
+ let IterableOfint = () => (IterableOfint = dart.constFn(core.Iterable$(core.int)))();
+ let JSArrayOfIterable = () => (JSArrayOfIterable = dart.constFn(_interceptors.JSArray$(core.Iterable)))();
+ let IterableAndintAndintTodynamic = () => (IterableAndintAndintTodynamic = dart.constFn(dart.definiteFunctionType(dart.dynamic, [core.Iterable, core.int, core.int])))();
+ let VoidToIterable = () => (VoidToIterable = dart.constFn(dart.definiteFunctionType(core.Iterable, [])))();
+ let dynamicTobool = () => (dynamicTobool = dart.constFn(dart.definiteFunctionType(core.bool, [dart.dynamic])))();
+ let VoidTodynamic = () => (VoidTodynamic = dart.constFn(dart.definiteFunctionType(dart.dynamic, [])))();
+ let const$;
+ iterable_skip_test.main = function() {
+ let list1 = JSArrayOfint().of([1, 2, 3]);
+ let list2 = const$ || (const$ = dart.constList([4, 5], core.int));
+ let list3 = JSArrayOfString().of([]);
+ let set1 = SetOfint().new();
+ set1.add(11);
+ set1.add(12);
+ set1.add(13);
+ let set2 = core.Set.new();
+ let skip0 = list1[dartx.skip](0);
+ expect$.Expect.isTrue(!core.List.is(skip0));
+ let it = skip0[dartx.iterator];
+ expect$.Expect.isNull(it.current);
+ expect$.Expect.isTrue(it.moveNext());
+ expect$.Expect.equals(1, it.current);
+ expect$.Expect.isTrue(it.moveNext());
+ expect$.Expect.equals(2, it.current);
+ expect$.Expect.isTrue(it.moveNext());
+ expect$.Expect.equals(3, it.current);
+ expect$.Expect.isFalse(it.moveNext());
+ expect$.Expect.isNull(it.current);
+ let skip1 = list1[dartx.skip](1);
+ expect$.Expect.isTrue(!core.List.is(skip1));
+ expect$.Expect.isTrue(!core.List.is(skip1[dartx.skip](2)[dartx.skip](1)));
+ it = skip1[dartx.iterator];
+ expect$.Expect.isNull(it.current);
+ expect$.Expect.isTrue(it.moveNext());
+ expect$.Expect.equals(2, it.current);
+ expect$.Expect.isTrue(it.moveNext());
+ expect$.Expect.equals(3, it.current);
+ expect$.Expect.isFalse(it.moveNext());
+ expect$.Expect.isNull(it.current);
+ let skip2 = list1[dartx.skip](2);
+ expect$.Expect.isTrue(!core.List.is(skip2));
+ expect$.Expect.isTrue(!core.List.is(skip2[dartx.skip](2)[dartx.skip](1)));
+ it = skip2[dartx.iterator];
+ expect$.Expect.isNull(it.current);
+ expect$.Expect.isTrue(it.moveNext());
+ expect$.Expect.equals(3, it.current);
+ expect$.Expect.isFalse(it.moveNext());
+ expect$.Expect.isNull(it.current);
+ let skip3 = list1[dartx.skip](3);
+ expect$.Expect.isTrue(!core.List.is(skip3));
+ expect$.Expect.isTrue(!core.List.is(skip3[dartx.skip](2)[dartx.skip](1)));
+ it = skip3[dartx.iterator];
+ expect$.Expect.isNull(it.current);
+ expect$.Expect.isFalse(it.moveNext());
+ expect$.Expect.isNull(it.current);
+ let skip4 = list1[dartx.skip](4);
+ expect$.Expect.isTrue(!core.List.is(skip4));
+ expect$.Expect.isTrue(!core.List.is(skip4[dartx.skip](2)[dartx.skip](1)));
+ it = skip4[dartx.iterator];
+ expect$.Expect.isNull(it.current);
+ expect$.Expect.isFalse(it.moveNext());
+ expect$.Expect.isNull(it.current);
+ skip0 = list1[dartx.skip](0);
+ skip1 = skip0[dartx.skip](1);
+ skip2 = skip1[dartx.skip](1);
+ skip3 = skip2[dartx.skip](1);
+ skip4 = skip3[dartx.skip](1);
+ it = skip0[dartx.iterator];
+ expect$.Expect.isNull(it.current);
+ expect$.Expect.isTrue(it.moveNext());
+ expect$.Expect.equals(1, it.current);
+ expect$.Expect.isTrue(it.moveNext());
+ expect$.Expect.equals(2, it.current);
+ expect$.Expect.isTrue(it.moveNext());
+ expect$.Expect.equals(3, it.current);
+ expect$.Expect.isFalse(it.moveNext());
+ expect$.Expect.isNull(it.current);
+ it = skip1[dartx.iterator];
+ expect$.Expect.isNull(it.current);
+ expect$.Expect.isTrue(it.moveNext());
+ expect$.Expect.equals(2, it.current);
+ expect$.Expect.isTrue(it.moveNext());
+ expect$.Expect.equals(3, it.current);
+ expect$.Expect.isFalse(it.moveNext());
+ expect$.Expect.isNull(it.current);
+ it = skip2[dartx.iterator];
+ expect$.Expect.isNull(it.current);
+ expect$.Expect.isTrue(it.moveNext());
+ expect$.Expect.equals(3, it.current);
+ expect$.Expect.isFalse(it.moveNext());
+ expect$.Expect.isNull(it.current);
+ it = skip3[dartx.iterator];
+ expect$.Expect.isNull(it.current);
+ expect$.Expect.isFalse(it.moveNext());
+ expect$.Expect.isNull(it.current);
+ it = skip4[dartx.iterator];
+ expect$.Expect.isNull(it.current);
+ expect$.Expect.isFalse(it.moveNext());
+ expect$.Expect.isNull(it.current);
+ skip0 = list2[dartx.skip](0);
+ expect$.Expect.isTrue(!core.List.is(skip0));
+ expect$.Expect.isTrue(!core.List.is(skip0[dartx.skip](2)[dartx.skip](1)));
+ it = skip0[dartx.iterator];
+ expect$.Expect.isNull(it.current);
+ expect$.Expect.isTrue(it.moveNext());
+ expect$.Expect.equals(4, it.current);
+ expect$.Expect.isTrue(it.moveNext());
+ expect$.Expect.equals(5, it.current);
+ expect$.Expect.isFalse(it.moveNext());
+ expect$.Expect.isNull(it.current);
+ skip1 = list2[dartx.skip](1);
+ expect$.Expect.isTrue(!core.List.is(skip1));
+ expect$.Expect.isTrue(!core.List.is(skip1[dartx.skip](2)[dartx.skip](1)));
+ it = skip1[dartx.iterator];
+ expect$.Expect.isNull(it.current);
+ expect$.Expect.isTrue(it.moveNext());
+ expect$.Expect.equals(5, it.current);
+ expect$.Expect.isFalse(it.moveNext());
+ expect$.Expect.isNull(it.current);
+ skip2 = list2[dartx.skip](2);
+ expect$.Expect.isTrue(!core.List.is(skip2));
+ expect$.Expect.isTrue(!core.List.is(skip2[dartx.skip](2)[dartx.skip](1)));
+ it = skip2[dartx.iterator];
+ expect$.Expect.isNull(it.current);
+ expect$.Expect.isFalse(it.moveNext());
+ expect$.Expect.isNull(it.current);
+ skip3 = list2[dartx.skip](3);
+ expect$.Expect.isTrue(!core.List.is(skip3));
+ expect$.Expect.isTrue(!core.List.is(skip3[dartx.skip](2)[dartx.skip](1)));
+ it = skip3[dartx.iterator];
+ expect$.Expect.isNull(it.current);
+ expect$.Expect.isFalse(it.moveNext());
+ expect$.Expect.isNull(it.current);
+ let skip02 = list3[dartx.skip](0);
+ expect$.Expect.isTrue(!core.List.is(skip02));
+ expect$.Expect.isTrue(!core.List.is(skip02[dartx.skip](2)[dartx.skip](1)));
+ let it2 = skip02[dartx.iterator];
+ expect$.Expect.isNull(it2.current);
+ expect$.Expect.isFalse(it2.moveNext());
+ expect$.Expect.isNull(it2.current);
+ let skip12 = list3[dartx.skip](1);
+ expect$.Expect.isTrue(!core.List.is(skip12));
+ expect$.Expect.isTrue(!core.List.is(skip12[dartx.skip](2)[dartx.skip](1)));
+ it2 = skip12[dartx.iterator];
+ expect$.Expect.isNull(it2.current);
+ expect$.Expect.isFalse(it2.moveNext());
+ expect$.Expect.isNull(it2.current);
+ skip0 = set1.skip(0);
+ let copied = skip0[dartx.toList]();
+ expect$.Expect.equals(3, copied[dartx.length]);
+ expect$.Expect.isTrue(set1.contains(copied[dartx.get](0)));
+ expect$.Expect.isTrue(set1.contains(copied[dartx.get](1)));
+ expect$.Expect.isTrue(set1.contains(copied[dartx.get](2)));
+ expect$.Expect.isTrue(copied[dartx.get](0) != copied[dartx.get](1));
+ expect$.Expect.isTrue(copied[dartx.get](0) != copied[dartx.get](2));
+ expect$.Expect.isTrue(copied[dartx.get](1) != copied[dartx.get](2));
+ it = skip0[dartx.iterator];
+ expect$.Expect.isNull(it.current);
+ expect$.Expect.isTrue(it.moveNext());
+ expect$.Expect.isNotNull(it.current);
+ expect$.Expect.isTrue(it.moveNext());
+ expect$.Expect.isNotNull(it.current);
+ expect$.Expect.isTrue(it.moveNext());
+ expect$.Expect.isNotNull(it.current);
+ expect$.Expect.isFalse(it.moveNext());
+ expect$.Expect.isNull(it.current);
+ skip1 = set1.skip(1);
+ copied = skip1[dartx.toList]();
+ expect$.Expect.equals(2, copied[dartx.length]);
+ expect$.Expect.isTrue(set1.contains(copied[dartx.get](0)));
+ expect$.Expect.isTrue(set1.contains(copied[dartx.get](1)));
+ expect$.Expect.isTrue(copied[dartx.get](0) != copied[dartx.get](1));
+ it = skip1[dartx.iterator];
+ expect$.Expect.isNull(it.current);
+ expect$.Expect.isTrue(it.moveNext());
+ expect$.Expect.isNotNull(it.current);
+ expect$.Expect.isTrue(it.moveNext());
+ expect$.Expect.isNotNull(it.current);
+ expect$.Expect.isFalse(it.moveNext());
+ expect$.Expect.isNull(it.current);
+ skip2 = set1.skip(2);
+ copied = skip2[dartx.toList]();
+ expect$.Expect.equals(1, copied[dartx.length]);
+ expect$.Expect.isTrue(set1.contains(copied[dartx.get](0)));
+ it = skip2[dartx.iterator];
+ expect$.Expect.isNull(it.current);
+ expect$.Expect.isTrue(it.moveNext());
+ expect$.Expect.isNotNull(it.current);
+ expect$.Expect.isFalse(it.moveNext());
+ expect$.Expect.isNull(it.current);
+ skip3 = set1.skip(3);
+ it = skip3[dartx.iterator];
+ expect$.Expect.isNull(it.current);
+ expect$.Expect.isFalse(it.moveNext());
+ expect$.Expect.isNull(it.current);
+ skip4 = set1.skip(4);
+ it = skip4[dartx.iterator];
+ expect$.Expect.isNull(it.current);
+ expect$.Expect.isFalse(it.moveNext());
+ expect$.Expect.isNull(it.current);
+ skip0 = IterableOfint()._check(set2.skip(0));
+ it = skip0[dartx.iterator];
+ expect$.Expect.isNull(it.current);
+ expect$.Expect.isFalse(it.moveNext());
+ expect$.Expect.isNull(it.current);
+ skip1 = IterableOfint()._check(set2.skip(1));
+ it = skip1[dartx.iterator];
+ expect$.Expect.isNull(it.current);
+ expect$.Expect.isFalse(it.moveNext());
+ expect$.Expect.isNull(it.current);
+ function testSkipTake(input, skip, take) {
+ let expected = [];
+ let iter = input[dartx.iterator];
+ for (let i = 0; i < dart.notNull(skip); i++)
+ iter.moveNext();
+ for (let i = 0; i < dart.notNull(take); i++) {
+ if (!dart.test(iter.moveNext())) break;
+ expected[dartx.add](iter.current);
+ }
+ expect$.Expect.listEquals(expected, input[dartx.skip](skip)[dartx.take](take)[dartx.toList]());
+ }
+ dart.fn(testSkipTake, IterableAndintAndintTodynamic());
+ let longList = JSArrayOfint().of([1, 4, 5, 3, 8, 11, 12, 6, 9, 10, 13, 7, 2, 14, 15]);
+ let bigSet = longList[dartx.toSet]();
+ for (let collection of JSArrayOfIterable().of([longList, longList[dartx.reversed], bigSet])) {
+ testSkipTake(collection, 0, 0);
+ testSkipTake(collection, 0, 5);
+ testSkipTake(collection, 0, 15);
+ testSkipTake(collection, 0, 25);
+ testSkipTake(collection, 5, 0);
+ testSkipTake(collection, 5, 5);
+ testSkipTake(collection, 5, 10);
+ testSkipTake(collection, 5, 20);
+ testSkipTake(collection, 15, 0);
+ testSkipTake(collection, 15, 5);
+ testSkipTake(collection, 20, 0);
+ testSkipTake(collection, 20, 5);
+ expect$.Expect.throws(dart.fn(() => longList[dartx.skip](-1), VoidToIterable()), dart.fn(e => core.RangeError.is(e), dynamicTobool()));
+ }
+ };
+ dart.fn(iterable_skip_test.main, VoidTodynamic());
+ // Exports:
+ exports.iterable_skip_test = iterable_skip_test;
+});
« no previous file with comments | « test/codegen/expect/corelib/iterable_single_where_test.js ('k') | test/codegen/expect/corelib/iterable_skip_while_test.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698