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

Side by Side Diff: test/codegen/expect/misc.js

Issue 1965213003: simplify constructors, fixes #564 (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 4 years, 7 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
« no previous file with comments | « test/codegen/expect/methods.js ('k') | test/codegen/expect/notnull.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 dart_library.library('misc', null, /* Imports */[ 1 dart_library.library('misc', null, /* Imports */[
2 'dart_sdk' 2 'dart_sdk'
3 ], function(exports, dart_sdk) { 3 ], function(exports, dart_sdk) {
4 'use strict'; 4 'use strict';
5 const core = dart_sdk.core; 5 const core = dart_sdk.core;
6 const dart = dart_sdk.dart; 6 const dart = dart_sdk.dart;
7 const dartx = dart_sdk.dartx; 7 const dartx = dart_sdk.dartx;
8 const misc = Object.create(null); 8 const misc = Object.create(null);
9 misc._Uninitialized = class _Uninitialized extends core.Object { 9 misc._Uninitialized = class _Uninitialized extends core.Object {
10 _Uninitialized() { 10 new() {
11 } 11 }
12 }; 12 };
13 dart.setSignature(misc._Uninitialized, { 13 dart.setSignature(misc._Uninitialized, {
14 constructors: () => ({_Uninitialized: [misc._Uninitialized, []]}) 14 constructors: () => ({new: [misc._Uninitialized, []]})
15 }); 15 });
16 misc.UNINITIALIZED = dart.const(new misc._Uninitialized()); 16 misc.UNINITIALIZED = dart.const(new misc._Uninitialized());
17 misc.Generic$ = dart.generic(T => { 17 misc.Generic$ = dart.generic(T => {
18 class Generic extends core.Object { 18 class Generic extends core.Object {
19 get type() { 19 get type() {
20 return dart.wrapType(misc.Generic); 20 return dart.wrapType(misc.Generic);
21 } 21 }
22 m() { 22 m() {
23 return core.print(dart.wrapType(T)); 23 return core.print(dart.wrapType(T));
24 } 24 }
25 } 25 }
26 dart.setSignature(Generic, { 26 dart.setSignature(Generic, {
27 methods: () => ({m: [dart.dynamic, []]}) 27 methods: () => ({m: [dart.dynamic, []]})
28 }); 28 });
29 return Generic; 29 return Generic;
30 }); 30 });
31 misc.Generic = misc.Generic$(); 31 misc.Generic = misc.Generic$();
32 misc.Base = class Base extends core.Object { 32 misc.Base = class Base extends core.Object {
33 Base() { 33 new() {
34 this.x = 1; 34 this.x = 1;
35 this.y = 2; 35 this.y = 2;
36 } 36 }
37 ['=='](obj) { 37 ['=='](obj) {
38 return dart.is(obj, misc.Base) && obj.x == this.x && obj.y == this.y; 38 return dart.is(obj, misc.Base) && obj.x == this.x && obj.y == this.y;
39 } 39 }
40 }; 40 };
41 misc.Derived = class Derived extends core.Object { 41 misc.Derived = class Derived extends core.Object {
42 Derived() { 42 new() {
43 this.z = 3; 43 this.z = 3;
44 } 44 }
45 ['=='](obj) { 45 ['=='](obj) {
46 return dart.is(obj, misc.Derived) && obj.z == this.z && super['=='](obj); 46 return dart.is(obj, misc.Derived) && obj.z == this.z && super['=='](obj);
47 } 47 }
48 }; 48 };
49 misc._isWhitespace = function(ch) { 49 misc._isWhitespace = function(ch) {
50 return ch == ' ' || ch == '\n' || ch == '\r' || ch == '\t'; 50 return ch == ' ' || ch == '\n' || ch == '\r' || ch == '\t';
51 }; 51 };
52 dart.fn(misc._isWhitespace, core.bool, [core.String]); 52 dart.fn(misc._isWhitespace, core.bool, [core.String]);
53 misc.expr = 'foo'; 53 misc.expr = 'foo';
54 misc._escapeMap = dart.const(dart.map({'\n': '\\n', '\r': '\\r', '\f': '\\f', '\b': '\\b', '\t': '\\t', '\v': '\\v', '': '\\x7F', [`\${${misc.expr}}`]: ''})) ; 54 misc._escapeMap = dart.const(dart.map({'\n': '\\n', '\r': '\\r', '\f': '\\f', '\b': '\\b', '\t': '\\t', '\v': '\\v', '': '\\x7F', [`\${${misc.expr}}`]: ''})) ;
55 misc.main = function() { 55 misc.main = function() {
56 core.print(dart.toString(1)); 56 core.print(dart.toString(1));
57 core.print(dart.toString(1.0)); 57 core.print(dart.toString(1.0));
58 core.print(dart.toString(1.1)); 58 core.print(dart.toString(1.1));
59 let x = 42; 59 let x = 42;
60 core.print(dart.equals(x, dart.wrapType(dart.dynamic))); 60 core.print(dart.equals(x, dart.wrapType(dart.dynamic)));
61 core.print(dart.equals(x, dart.wrapType(misc.Generic))); 61 core.print(dart.equals(x, dart.wrapType(misc.Generic)));
62 core.print(new (misc.Generic$(core.int))().type); 62 core.print(new (misc.Generic$(core.int))().type);
63 core.print(dart.equals(new misc.Derived(), new misc.Derived())); 63 core.print(dart.equals(new misc.Derived(), new misc.Derived()));
64 new (misc.Generic$(core.int))().m(); 64 new (misc.Generic$(core.int))().m();
65 }; 65 };
66 dart.fn(misc.main); 66 dart.fn(misc.main);
67 // Exports: 67 // Exports:
68 exports.misc = misc; 68 exports.misc = misc;
69 }); 69 });
OLDNEW
« no previous file with comments | « test/codegen/expect/methods.js ('k') | test/codegen/expect/notnull.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698