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

Side by Side Diff: test/codegen/expect/corelib/expando_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 unified diff | Download patch
OLDNEW
(Empty)
1 dart_library.library('corelib/expando_test', null, /* Imports */[
2 'dart_sdk',
3 'expect'
4 ], function load__expando_test(exports, dart_sdk, expect) {
5 'use strict';
6 const core = dart_sdk.core;
7 const _interceptors = dart_sdk._interceptors;
8 const dart = dart_sdk.dart;
9 const dartx = dart_sdk.dartx;
10 const expect$ = expect.expect;
11 const expando_test = Object.create(null);
12 let ExpandoOfint = () => (ExpandoOfint = dart.constFn(core.Expando$(core.int)) )();
13 let JSArrayOfint = () => (JSArrayOfint = dart.constFn(_interceptors.JSArray$(c ore.int)))();
14 let JSArrayOfObject = () => (JSArrayOfObject = dart.constFn(_interceptors.JSAr ray$(core.Object)))();
15 let VoidToint = () => (VoidToint = dart.constFn(dart.definiteFunctionType(core .int, [])))();
16 let dynamicTobool = () => (dynamicTobool = dart.constFn(dart.definiteFunctionT ype(core.bool, [dart.dynamic])))();
17 let VoidTodynamic = () => (VoidTodynamic = dart.constFn(dart.definiteFunctionT ype(dart.dynamic, [])))();
18 let const$;
19 let const$0;
20 expando_test.ExpandoTest = class ExpandoTest extends core.Object {
21 static testMain() {
22 expando_test.ExpandoTest.visits = new (ExpandoOfint())('visits');
23 let legal = JSArrayOfObject().of([new core.Object(), core.List.new(), JSAr rayOfint().of([1, 2, 3]), const$ || (const$ = dart.constList([1, 2, 3], core.int )), core.Map.new(), dart.map({x: 1, y: 2}), const$0 || (const$0 = dart.const(dar t.map({x: 1, y: 2}))), new core.Expando(), new core.Expando('horse')]);
24 for (let object of legal) {
25 expando_test.ExpandoTest.testNamedExpando(object);
26 expando_test.ExpandoTest.testUnnamedExpando(object);
27 }
28 for (let object of legal) {
29 expect$.Expect.equals(2, expando_test.ExpandoTest.visits.get(object), da rt.str`${object}`);
30 }
31 expando_test.ExpandoTest.testIllegal();
32 expando_test.ExpandoTest.testIdentity();
33 }
34 static visit(object) {
35 let count = expando_test.ExpandoTest.visits.get(object);
36 count = count == null ? 1 : dart.notNull(count) + 1;
37 expando_test.ExpandoTest.visits.set(object, count);
38 }
39 static testNamedExpando(object) {
40 let expando = new (ExpandoOfint())('myexpando');
41 expect$.Expect.equals('myexpando', expando.name);
42 expect$.Expect.isTrue(expando.toString()[dartx.startsWith]('Expando:myexpa ndo'));
43 expando_test.ExpandoTest.testExpando(expando, object);
44 }
45 static testUnnamedExpando(object) {
46 let expando = new (ExpandoOfint())();
47 expect$.Expect.isNull(expando.name);
48 expect$.Expect.isTrue(expando.toString()[dartx.startsWith]('Expando:'));
49 expando_test.ExpandoTest.testExpando(expando, object);
50 }
51 static testExpando(expando, object) {
52 expando_test.ExpandoTest.visit(object);
53 expect$.Expect.isNull(expando.get(object));
54 expando.set(object, 42);
55 expect$.Expect.equals(42, expando.get(object));
56 expando.set(object, null);
57 expect$.Expect.isNull(expando.get(object));
58 let alternative = new (ExpandoOfint())('myexpando');
59 expect$.Expect.isNull(alternative.get(object));
60 alternative.set(object, 87);
61 expect$.Expect.isNull(expando.get(object));
62 expando.set(object, 99);
63 expect$.Expect.equals(99, expando.get(object));
64 expect$.Expect.equals(87, alternative.get(object));
65 }
66 static testIllegal() {
67 let expando = new (ExpandoOfint())();
68 expect$.Expect.throws(dart.fn(() => expando.get(null), VoidToint()), dart. fn(exception => core.ArgumentError.is(exception), dynamicTobool()), "null");
69 expect$.Expect.throws(dart.fn(() => expando.get('string'), VoidToint()), d art.fn(exception => core.ArgumentError.is(exception), dynamicTobool()), "'string '");
70 expect$.Expect.throws(dart.fn(() => expando.get('string'), VoidToint()), d art.fn(exception => core.ArgumentError.is(exception), dynamicTobool()), "'string '");
71 expect$.Expect.throws(dart.fn(() => expando.get(42), VoidToint()), dart.fn (exception => core.ArgumentError.is(exception), dynamicTobool()), "42");
72 expect$.Expect.throws(dart.fn(() => expando.get(42.87), VoidToint()), dart .fn(exception => core.ArgumentError.is(exception), dynamicTobool()), "42.87");
73 expect$.Expect.throws(dart.fn(() => expando.get(true), VoidToint()), dart. fn(exception => core.ArgumentError.is(exception), dynamicTobool()), "true");
74 expect$.Expect.throws(dart.fn(() => expando.get(false), VoidToint()), dart .fn(exception => core.ArgumentError.is(exception), dynamicTobool()), "false");
75 }
76 static testIdentity() {
77 let expando = new (ExpandoOfint())();
78 let m1 = new expando_test.Mutable(1);
79 let m2 = new expando_test.Mutable(7);
80 let m3 = new expando_test.Mutable(13);
81 expando.set(m1, 42);
82 expect$.Expect.equals(42, expando.get(m1));
83 m1.id = 37;
84 expect$.Expect.equals(42, expando.get(m1));
85 expando.set(m2, 37);
86 expando.set(m3, 10);
87 m3.id = 1;
88 expect$.Expect.equals(42, expando.get(m1));
89 expect$.Expect.equals(37, expando.get(m2));
90 expect$.Expect.equals(10, expando.get(m3));
91 }
92 };
93 dart.setSignature(expando_test.ExpandoTest, {
94 statics: () => ({
95 testMain: dart.definiteFunctionType(dart.dynamic, []),
96 visit: dart.definiteFunctionType(dart.dynamic, [dart.dynamic]),
97 testNamedExpando: dart.definiteFunctionType(dart.dynamic, [dart.dynamic]),
98 testUnnamedExpando: dart.definiteFunctionType(dart.dynamic, [dart.dynamic] ),
99 testExpando: dart.definiteFunctionType(dart.dynamic, [core.Expando$(core.i nt), dart.dynamic]),
100 testIllegal: dart.definiteFunctionType(dart.dynamic, []),
101 testIdentity: dart.definiteFunctionType(dart.dynamic, [])
102 }),
103 names: ['testMain', 'visit', 'testNamedExpando', 'testUnnamedExpando', 'test Expando', 'testIllegal', 'testIdentity']
104 });
105 expando_test.ExpandoTest.visits = null;
106 expando_test.main = function() {
107 return expando_test.ExpandoTest.testMain();
108 };
109 dart.fn(expando_test.main, VoidTodynamic());
110 expando_test.Mutable = class Mutable extends core.Object {
111 new(id) {
112 this.id = id;
113 }
114 get hashCode() {
115 return this.id;
116 }
117 ['=='](other) {
118 return expando_test.Mutable.is(other) && other.id == this.id;
119 }
120 };
121 dart.setSignature(expando_test.Mutable, {
122 constructors: () => ({new: dart.definiteFunctionType(expando_test.Mutable, [ core.int])})
123 });
124 // Exports:
125 exports.expando_test = expando_test;
126 });
OLDNEW
« no previous file with comments | « test/codegen/expect/corelib/exception_implementation_test.js ('k') | test/codegen/expect/corelib/expression_test.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698