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

Unified Diff: test/codegen/expect/corelib/map_from_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/map_from_test.js
diff --git a/test/codegen/expect/corelib/map_from_test.js b/test/codegen/expect/corelib/map_from_test.js
new file mode 100644
index 0000000000000000000000000000000000000000..634b4836040e524bb447373c50f25c6be7266f25
--- /dev/null
+++ b/test/codegen/expect/corelib/map_from_test.js
@@ -0,0 +1,103 @@
+dart_library.library('corelib/map_from_test', null, /* Imports */[
+ 'dart_sdk',
+ 'expect'
+], function load__map_from_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 map_from_test = Object.create(null);
+ let VoidTodynamic = () => (VoidTodynamic = dart.constFn(dart.definiteFunctionType(dart.dynamic, [])))();
+ let dynamicAnddynamicTodynamic = () => (dynamicAnddynamicTodynamic = dart.constFn(dart.definiteFunctionType(dart.dynamic, [dart.dynamic, dart.dynamic])))();
+ let dynamicToint = () => (dynamicToint = dart.constFn(dart.definiteFunctionType(core.int, [dart.dynamic])))();
+ map_from_test.main = function() {
+ map_from_test.testWithConstMap();
+ map_from_test.testWithNonConstMap();
+ map_from_test.testWithHashMap();
+ map_from_test.testWithLinkedMap();
+ };
+ dart.fn(map_from_test.main, VoidTodynamic());
+ let const$;
+ map_from_test.testWithConstMap = function() {
+ let map = const$ || (const$ = dart.const(dart.map({b: 42, a: 43})));
+ let otherMap = core.Map.from(map);
+ expect$.Expect.isTrue(core.Map.is(otherMap));
+ expect$.Expect.isTrue(collection.HashMap.is(otherMap));
+ expect$.Expect.isTrue(collection.LinkedHashMap.is(otherMap));
+ expect$.Expect.equals(2, otherMap[dartx.length]);
+ expect$.Expect.equals(2, otherMap[dartx.keys][dartx.length]);
+ expect$.Expect.equals(2, otherMap[dartx.values][dartx.length]);
+ let count = dart.fn(map => {
+ let cnt = 0;
+ dart.dsend(map, 'forEach', dart.fn((a, b) => {
+ cnt = dart.notNull(cnt) + dart.notNull(core.int._check(b));
+ }, dynamicAnddynamicTodynamic()));
+ return cnt;
+ }, dynamicToint());
+ expect$.Expect.equals(42 + 43, dart.dcall(count, map));
+ expect$.Expect.equals(dart.dcall(count, map), dart.dcall(count, otherMap));
+ };
+ dart.fn(map_from_test.testWithConstMap, VoidTodynamic());
+ map_from_test.testWithNonConstMap = function() {
+ let map = dart.map({b: 42, a: 43});
+ let otherMap = core.Map.from(map);
+ expect$.Expect.isTrue(core.Map.is(otherMap));
+ expect$.Expect.isTrue(collection.HashMap.is(otherMap));
+ expect$.Expect.isTrue(collection.LinkedHashMap.is(otherMap));
+ expect$.Expect.equals(2, otherMap[dartx.length]);
+ expect$.Expect.equals(2, otherMap[dartx.keys][dartx.length]);
+ expect$.Expect.equals(2, otherMap[dartx.values][dartx.length]);
+ function count(map) {
+ let count = 0;
+ dart.dsend(map, 'forEach', dart.fn((a, b) => {
+ count = dart.notNull(count) + dart.notNull(core.int._check(b));
+ }, dynamicAnddynamicTodynamic()));
+ return count;
+ }
+ dart.fn(count, dynamicToint());
+ ;
+ expect$.Expect.equals(42 + 43, count(map));
+ expect$.Expect.equals(count(map), count(otherMap));
+ map[dartx.set]('c', 44);
+ expect$.Expect.equals(3, map[dartx.length]);
+ expect$.Expect.equals(2, otherMap[dartx.length]);
+ expect$.Expect.equals(2, otherMap[dartx.keys][dartx.length]);
+ expect$.Expect.equals(2, otherMap[dartx.values][dartx.length]);
+ otherMap[dartx.set]('c', 44);
+ expect$.Expect.equals(3, map[dartx.length]);
+ expect$.Expect.equals(3, otherMap[dartx.length]);
+ expect$.Expect.equals(3, otherMap[dartx.keys][dartx.length]);
+ expect$.Expect.equals(3, otherMap[dartx.values][dartx.length]);
+ };
+ dart.fn(map_from_test.testWithNonConstMap, VoidTodynamic());
+ let const$0;
+ map_from_test.testWithHashMap = function() {
+ let map = const$0 || (const$0 = dart.const(dart.map({b: 1, a: 2, c: 3})));
+ let otherMap = collection.HashMap.from(map);
+ expect$.Expect.isTrue(core.Map.is(otherMap));
+ expect$.Expect.isTrue(collection.HashMap.is(otherMap));
+ expect$.Expect.isTrue(!collection.LinkedHashMap.is(otherMap));
+ let i = 1;
+ for (let val of map[dartx.values]) {
+ expect$.Expect.equals(i++, val);
+ }
+ };
+ dart.fn(map_from_test.testWithHashMap, VoidTodynamic());
+ let const$1;
+ map_from_test.testWithLinkedMap = function() {
+ let map = const$1 || (const$1 = dart.const(dart.map({b: 1, a: 2, c: 3})));
+ let otherMap = collection.LinkedHashMap.from(map);
+ expect$.Expect.isTrue(core.Map.is(otherMap));
+ expect$.Expect.isTrue(collection.HashMap.is(otherMap));
+ expect$.Expect.isTrue(collection.LinkedHashMap.is(otherMap));
+ let i = 1;
+ for (let val of map[dartx.values]) {
+ expect$.Expect.equals(i++, val);
+ }
+ };
+ dart.fn(map_from_test.testWithLinkedMap, VoidTodynamic());
+ // Exports:
+ exports.map_from_test = map_from_test;
+});
« no previous file with comments | « test/codegen/expect/corelib/map_from_iterables_test.js ('k') | test/codegen/expect/corelib/map_index_test.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698