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

Unified Diff: test/codegen/expect/corelib/linked_hash_map_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/linked_hash_map_test.js
diff --git a/test/codegen/expect/corelib/linked_hash_map_test.js b/test/codegen/expect/corelib/linked_hash_map_test.js
new file mode 100644
index 0000000000000000000000000000000000000000..bf46655cfa316b1274604c8ccfae8e3d2363ed56
--- /dev/null
+++ b/test/codegen/expect/corelib/linked_hash_map_test.js
@@ -0,0 +1,128 @@
+dart_library.library('corelib/linked_hash_map_test', null, /* Imports */[
+ 'dart_sdk',
+ 'expect'
+], function load__linked_hash_map_test(exports, dart_sdk, expect) {
+ 'use strict';
+ const core = dart_sdk.core;
+ const collection = dart_sdk.collection;
+ const dart = dart_sdk.dart;
+ const dartx = dart_sdk.dartx;
+ const expect$ = expect.expect;
+ const linked_hash_map_test = Object.create(null);
+ let ListOfString = () => (ListOfString = dart.constFn(core.List$(core.String)))();
+ let ListOfint = () => (ListOfint = dart.constFn(core.List$(core.int)))();
+ let VoidTodynamic = () => (VoidTodynamic = dart.constFn(dart.definiteFunctionType(dart.dynamic, [])))();
+ let ListOfStringTodynamic = () => (ListOfStringTodynamic = dart.constFn(dart.definiteFunctionType(dart.dynamic, [ListOfString()])))();
+ let ListOfintTodynamic = () => (ListOfintTodynamic = dart.constFn(dart.definiteFunctionType(dart.dynamic, [ListOfint()])))();
+ let ObjectAndObjectTodynamic = () => (ObjectAndObjectTodynamic = dart.constFn(dart.definiteFunctionType(dart.dynamic, [core.Object, core.Object])))();
+ let ObjectTodynamic = () => (ObjectTodynamic = dart.constFn(dart.definiteFunctionType(dart.dynamic, [core.Object])))();
+ let const$;
+ let const$0;
+ let const$1;
+ let const$2;
+ let const$3;
+ linked_hash_map_test.LinkedHashMapTest = class LinkedHashMapTest extends core.Object {
+ static testMain() {
+ let map = collection.LinkedHashMap.new();
+ map[dartx.set]("a", 1);
+ map[dartx.set]("b", 2);
+ map[dartx.set]("c", 3);
+ map[dartx.set]("d", 4);
+ map[dartx.set]("e", 5);
+ let keys = ListOfString().new(5);
+ let values = ListOfint().new(5);
+ let index = null;
+ function clear() {
+ index = 0;
+ for (let i = 0; i < dart.notNull(keys[dartx.length]); i++) {
+ keys[dartx.set](i, null);
+ values[dartx.set](i, null);
+ }
+ }
+ dart.fn(clear, VoidTodynamic());
+ function verifyKeys(correctKeys) {
+ for (let i = 0; i < dart.notNull(correctKeys[dartx.length]); i++) {
+ expect$.Expect.equals(correctKeys[dartx.get](i), keys[dartx.get](i));
+ }
+ }
+ dart.fn(verifyKeys, ListOfStringTodynamic());
+ function verifyValues(correctValues) {
+ for (let i = 0; i < dart.notNull(correctValues[dartx.length]); i++) {
+ expect$.Expect.equals(correctValues[dartx.get](i), values[dartx.get](i));
+ }
+ }
+ dart.fn(verifyValues, ListOfintTodynamic());
+ function testForEachMap(key, value) {
+ expect$.Expect.equals(map[dartx.get](key), value);
+ keys[dartx.set](index, core.String._check(key));
+ values[dartx.set](index, core.int._check(value));
+ index = dart.notNull(index) + 1;
+ }
+ dart.fn(testForEachMap, ObjectAndObjectTodynamic());
+ function testForEachValue(v) {
+ values[dartx.set]((() => {
+ let x = index;
+ index = dart.notNull(x) + 1;
+ return x;
+ })(), core.int._check(v));
+ }
+ dart.fn(testForEachValue, ObjectTodynamic());
+ function testForEachKey(v) {
+ keys[dartx.set]((() => {
+ let x = index;
+ index = dart.notNull(x) + 1;
+ return x;
+ })(), core.String._check(v));
+ }
+ dart.fn(testForEachKey, ObjectTodynamic());
+ let keysInOrder = const$ || (const$ = dart.constList(["a", "b", "c", "d", "e"], core.String));
+ let valuesInOrder = const$0 || (const$0 = dart.constList([1, 2, 3, 4, 5], core.int));
+ clear();
+ map[dartx.forEach](testForEachMap);
+ verifyKeys(keysInOrder);
+ verifyValues(valuesInOrder);
+ clear();
+ map[dartx.keys][dartx.forEach](testForEachKey);
+ verifyKeys(keysInOrder);
+ clear();
+ map[dartx.values][dartx.forEach](testForEachValue);
+ verifyValues(valuesInOrder);
+ map[dartx.remove]("b");
+ map[dartx.set]("b", 6);
+ let keysAfterBMove = const$1 || (const$1 = dart.constList(["a", "c", "d", "e", "b"], core.String));
+ let valuesAfterBMove = const$2 || (const$2 = dart.constList([1, 3, 4, 5, 6], core.int));
+ clear();
+ map[dartx.forEach](testForEachMap);
+ verifyKeys(keysAfterBMove);
+ verifyValues(valuesAfterBMove);
+ clear();
+ map[dartx.keys][dartx.forEach](testForEachKey);
+ verifyKeys(keysAfterBMove);
+ clear();
+ map[dartx.values][dartx.forEach](testForEachValue);
+ verifyValues(valuesAfterBMove);
+ map[dartx.set]("a", 0);
+ let valuesAfterAUpdate = const$3 || (const$3 = dart.constList([0, 3, 4, 5, 6], core.int));
+ clear();
+ map[dartx.forEach](testForEachMap);
+ verifyKeys(keysAfterBMove);
+ verifyValues(valuesAfterAUpdate);
+ clear();
+ map[dartx.keys][dartx.forEach](testForEachKey);
+ verifyKeys(keysAfterBMove);
+ clear();
+ map[dartx.values][dartx.forEach](testForEachValue);
+ verifyValues(valuesAfterAUpdate);
+ }
+ };
+ dart.setSignature(linked_hash_map_test.LinkedHashMapTest, {
+ statics: () => ({testMain: dart.definiteFunctionType(dart.void, [])}),
+ names: ['testMain']
+ });
+ linked_hash_map_test.main = function() {
+ linked_hash_map_test.LinkedHashMapTest.testMain();
+ };
+ dart.fn(linked_hash_map_test.main, VoidTodynamic());
+ // Exports:
+ exports.linked_hash_map_test = linked_hash_map_test;
+});
« no previous file with comments | « test/codegen/expect/corelib/linked_hash_map_from_iterables_test.js ('k') | test/codegen/expect/corelib/list_as_map_test.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698