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

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

Issue 1879373004: Implement modular compilation (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 4 years, 8 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
« no previous file with comments | « test/codegen/expect/es6_modules.txt ('k') | test/codegen/expect/expect.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/codegen/expect/expect.js
diff --git a/test/codegen/expect/expect.js b/test/codegen/expect/expect.js
index c907be161a945f86e757565b199d4c6ce0e5be3b..3f6ee6519232c67333c3ec9066790f2a85c7e622 100644
--- a/test/codegen/expect/expect.js
+++ b/test/codegen/expect/expect.js
@@ -1,11 +1,12 @@
dart_library.library('expect', null, /* Imports */[
- 'dart/_runtime',
- 'dart/core'
-], /* Lazy imports */[
-], function(exports, dart, core) {
+ 'dart_sdk'
+], function(exports, dart_sdk) {
'use strict';
- let dartx = dart.dartx;
- class Expect extends core.Object {
+ const core = dart_sdk.core;
+ const dart = dart_sdk.dart;
+ const dartx = dart_sdk.dartx;
+ const expect = Object.create(null);
+ expect.Expect = class Expect extends core.Object {
static _truncateString(string, start, end, length) {
if (dart.notNull(end) - dart.notNull(start) > dart.notNull(length)) {
end = dart.notNull(start) + dart.notNull(length);
@@ -44,8 +45,8 @@ dart_library.library('expect', null, /* Imports */[
i++;
}
let end = i;
- let truncExpected = Expect._truncateString(expected, start, end, 20);
- let truncActual = Expect._truncateString(actual, start, end, 20);
+ let truncExpected = expect.Expect._truncateString(expected, start, end, 20);
+ let truncActual = expect.Expect._truncateString(actual, start, end, 20);
return `at index ${start}: Expected <${truncExpected}>, ` + `Found: <${truncActual}>`;
}
}
@@ -54,47 +55,47 @@ dart_library.library('expect', null, /* Imports */[
static equals(expected, actual, reason) {
if (reason === void 0) reason = null;
if (dart.equals(expected, actual)) return;
- let msg = Expect._getMessage(reason);
+ let msg = expect.Expect._getMessage(reason);
if (typeof expected == 'string' && typeof actual == 'string') {
- let stringDifference = Expect._stringDifference(expected, actual);
+ let stringDifference = expect.Expect._stringDifference(expected, actual);
if (stringDifference != null) {
- Expect._fail(`Expect.equals(${stringDifference}${msg}) fails.`);
+ expect.Expect._fail(`Expect.equals(${stringDifference}${msg}) fails.`);
}
}
- Expect._fail(`Expect.equals(expected: <${expected}>, actual: <${actual}>${msg}) fails.`);
+ expect.Expect._fail(`Expect.equals(expected: <${expected}>, actual: <${actual}>${msg}) fails.`);
}
static isTrue(actual, reason) {
if (reason === void 0) reason = null;
- if (dart.notNull(_identical(actual, true))) return;
- let msg = Expect._getMessage(reason);
- Expect._fail(`Expect.isTrue(${actual}${msg}) fails.`);
+ if (dart.notNull(expect._identical(actual, true))) return;
+ let msg = expect.Expect._getMessage(reason);
+ expect.Expect._fail(`Expect.isTrue(${actual}${msg}) fails.`);
}
static isFalse(actual, reason) {
if (reason === void 0) reason = null;
- if (dart.notNull(_identical(actual, false))) return;
- let msg = Expect._getMessage(reason);
- Expect._fail(`Expect.isFalse(${actual}${msg}) fails.`);
+ if (dart.notNull(expect._identical(actual, false))) return;
+ let msg = expect.Expect._getMessage(reason);
+ expect.Expect._fail(`Expect.isFalse(${actual}${msg}) fails.`);
}
static isNull(actual, reason) {
if (reason === void 0) reason = null;
if (null == actual) return;
- let msg = Expect._getMessage(reason);
- Expect._fail(`Expect.isNull(actual: <${actual}>${msg}) fails.`);
+ let msg = expect.Expect._getMessage(reason);
+ expect.Expect._fail(`Expect.isNull(actual: <${actual}>${msg}) fails.`);
}
static isNotNull(actual, reason) {
if (reason === void 0) reason = null;
if (null != actual) return;
- let msg = Expect._getMessage(reason);
- Expect._fail(`Expect.isNotNull(actual: <${actual}>${msg}) fails.`);
+ let msg = expect.Expect._getMessage(reason);
+ expect.Expect._fail(`Expect.isNotNull(actual: <${actual}>${msg}) fails.`);
}
static identical(expected, actual, reason) {
if (reason === void 0) reason = null;
- if (dart.notNull(_identical(expected, actual))) return;
- let msg = Expect._getMessage(reason);
- Expect._fail(`Expect.identical(expected: <${expected}>, actual: <${actual}>${msg}) ` + "fails.");
+ if (dart.notNull(expect._identical(expected, actual))) return;
+ let msg = expect.Expect._getMessage(reason);
+ expect.Expect._fail(`Expect.identical(expected: <${expected}>, actual: <${actual}>${msg}) ` + "fails.");
}
static fail(msg) {
- Expect._fail(`Expect.fail('${msg}')`);
+ expect.Expect._fail(`Expect.fail('${msg}')`);
}
static approxEquals(expected, actual, tolerance, reason) {
if (tolerance === void 0) tolerance = null;
@@ -103,50 +104,50 @@ dart_library.library('expect', null, /* Imports */[
tolerance = (dart.notNull(expected) / 10000.0)[dartx.abs]();
}
if (dart.notNull((dart.notNull(expected) - dart.notNull(actual))[dartx.abs]()) <= dart.notNull(tolerance)) return;
- let msg = Expect._getMessage(reason);
- Expect._fail(`Expect.approxEquals(expected:<${expected}>, actual:<${actual}>, ` + `tolerance:<${tolerance}>${msg}) fails`);
+ let msg = expect.Expect._getMessage(reason);
+ expect.Expect._fail(`Expect.approxEquals(expected:<${expected}>, actual:<${actual}>, ` + `tolerance:<${tolerance}>${msg}) fails`);
}
static notEquals(unexpected, actual, reason) {
if (reason === void 0) reason = null;
if (!dart.equals(unexpected, actual)) return;
- let msg = Expect._getMessage(reason);
- Expect._fail(`Expect.notEquals(unexpected: <${unexpected}>, actual:<${actual}>${msg}) ` + "fails.");
+ let msg = expect.Expect._getMessage(reason);
+ expect.Expect._fail(`Expect.notEquals(unexpected: <${unexpected}>, actual:<${actual}>${msg}) ` + "fails.");
}
static listEquals(expected, actual, reason) {
if (reason === void 0) reason = null;
- let msg = Expect._getMessage(reason);
+ let msg = expect.Expect._getMessage(reason);
let n = dart.notNull(expected[dartx.length]) < dart.notNull(actual[dartx.length]) ? expected[dartx.length] : actual[dartx.length];
for (let i = 0; i < dart.notNull(n); i++) {
if (!dart.equals(expected[dartx.get](i), actual[dartx.get](i))) {
- Expect._fail(`Expect.listEquals(at index ${i}, ` + `expected: <${expected[dartx.get](i)}>, actual: <${actual[dartx.get](i)}>${msg}) fails`);
+ expect.Expect._fail(`Expect.listEquals(at index ${i}, ` + `expected: <${expected[dartx.get](i)}>, actual: <${actual[dartx.get](i)}>${msg}) fails`);
}
}
if (expected[dartx.length] != actual[dartx.length]) {
- Expect._fail('Expect.listEquals(list length, ' + `expected: <${expected[dartx.length]}>, actual: <${actual[dartx.length]}>${msg}) ` + 'fails: Next element <' + `${dart.notNull(expected[dartx.length]) > dart.notNull(n) ? expected[dartx.get](n) : actual[dartx.get](n)}>`);
+ expect.Expect._fail('Expect.listEquals(list length, ' + `expected: <${expected[dartx.length]}>, actual: <${actual[dartx.length]}>${msg}) ` + 'fails: Next element <' + `${dart.notNull(expected[dartx.length]) > dart.notNull(n) ? expected[dartx.get](n) : actual[dartx.get](n)}>`);
}
}
static mapEquals(expected, actual, reason) {
if (reason === void 0) reason = null;
- let msg = Expect._getMessage(reason);
+ let msg = expect.Expect._getMessage(reason);
for (let key of expected[dartx.keys]) {
if (!dart.notNull(actual[dartx.containsKey](key))) {
- Expect._fail(`Expect.mapEquals(missing expected key: <${key}>${msg}) fails`);
+ expect.Expect._fail(`Expect.mapEquals(missing expected key: <${key}>${msg}) fails`);
}
- Expect.equals(expected[dartx.get](key), actual[dartx.get](key));
+ expect.Expect.equals(expected[dartx.get](key), actual[dartx.get](key));
}
for (let key of actual[dartx.keys]) {
if (!dart.notNull(expected[dartx.containsKey](key))) {
- Expect._fail(`Expect.mapEquals(unexpected key: <${key}>${msg}) fails`);
+ expect.Expect._fail(`Expect.mapEquals(unexpected key: <${key}>${msg}) fails`);
}
}
}
static stringEquals(expected, actual, reason) {
if (reason === void 0) reason = null;
if (expected == actual) return;
- let msg = Expect._getMessage(reason);
+ let msg = expect.Expect._getMessage(reason);
let defaultMessage = `Expect.stringEquals(expected: <${expected}>", <${actual}>${msg}) fails`;
if (expected == null || actual == null) {
- Expect._fail(`${defaultMessage}`);
+ expect.Expect._fail(`${defaultMessage}`);
}
let left = 0;
let right = 0;
@@ -182,7 +183,7 @@ dart_library.library('expect', null, /* Imports */[
if (left <= 10) leftLead = "";
if (right <= 10) rightTail = "";
let diff = `\nDiff (${left}..${dart.notNull(eLen) - right}/${dart.notNull(aLen) - right}):\n` + `${leftLead}${leftSnippet}[ ${eSnippet} ]${rightSnippet}${rightTail}\n` + `${leftLead}${leftSnippet}[ ${aSnippet} ]${rightSnippet}${rightTail}`;
- Expect._fail(`${defaultMessage}${diff}`);
+ expect.Expect._fail(`${defaultMessage}${diff}`);
}
static setEquals(expected, actual, reason) {
if (reason === void 0) reason = null;
@@ -191,7 +192,7 @@ dart_library.library('expect', null, /* Imports */[
let extraSet = core.Set.from(actual);
extraSet.removeAll(expected);
if (dart.notNull(extraSet.isEmpty) && dart.notNull(missingSet.isEmpty)) return;
- let msg = Expect._getMessage(reason);
+ let msg = expect.Expect._getMessage(reason);
let sb = new core.StringBuffer(`Expect.setEquals(${msg}) fails`);
if (!dart.notNull(missingSet.isEmpty)) {
sb.write('\nExpected collection does not contain: ');
@@ -205,14 +206,14 @@ dart_library.library('expect', null, /* Imports */[
for (let val of extraSet) {
sb.write(`${val} `);
}
- Expect._fail(sb.toString());
+ expect.Expect._fail(sb.toString());
}
static throws(f, check, reason) {
if (check === void 0) check = null;
if (reason === void 0) reason = null;
let msg = reason == null ? "" : `(${reason})`;
- if (!dart.is(f, _Nullary)) {
- Expect._fail(`Expect.throws${msg}: Function f not callable with zero arguments`);
+ if (!dart.is(f, expect._Nullary)) {
+ expect.Expect._fail(`Expect.throws${msg}: Function f not callable with zero arguments`);
}
try {
f();
@@ -220,22 +221,22 @@ dart_library.library('expect', null, /* Imports */[
let s = dart.stackTrace(e);
if (check != null) {
if (!dart.notNull(dart.dcall(check, e))) {
- Expect._fail(`Expect.throws${msg}: Unexpected '${e}'\n${s}`);
+ expect.Expect._fail(`Expect.throws${msg}: Unexpected '${e}'\n${s}`);
}
}
return;
}
- Expect._fail(`Expect.throws${msg} fails: Did not throw`);
+ expect.Expect._fail(`Expect.throws${msg} fails: Did not throw`);
}
static _getMessage(reason) {
return reason == null ? "" : `, '${reason}'`;
}
static _fail(message) {
- dart.throw(new ExpectException(message));
+ dart.throw(new expect.ExpectException(message));
}
- }
- dart.setSignature(Expect, {
+ };
+ dart.setSignature(expect.Expect, {
statics: () => ({
_truncateString: [core.String, [core.String, core.int, core.int, core.int]],
_stringDifference: [core.String, [core.String, core.String]],
@@ -252,55 +253,51 @@ dart_library.library('expect', null, /* Imports */[
mapEquals: [dart.void, [core.Map, core.Map], [core.String]],
stringEquals: [dart.void, [core.String, core.String], [core.String]],
setEquals: [dart.void, [core.Iterable, core.Iterable], [core.String]],
- throws: [dart.void, [dart.functionType(dart.void, [])], [_CheckExceptionFn, core.String]],
+ throws: [dart.void, [dart.functionType(dart.void, [])], [expect._CheckExceptionFn, core.String]],
_getMessage: [core.String, [core.String]],
_fail: [dart.void, [core.String]]
}),
names: ['_truncateString', '_stringDifference', 'equals', 'isTrue', 'isFalse', 'isNull', 'isNotNull', 'identical', 'fail', 'approxEquals', 'notEquals', 'listEquals', 'mapEquals', 'stringEquals', 'setEquals', 'throws', '_getMessage', '_fail']
});
- function _identical(a, b) {
+ expect._identical = function(a, b) {
return core.identical(a, b);
- }
- dart.fn(_identical, core.bool, [dart.dynamic, dart.dynamic]);
- const _CheckExceptionFn = dart.typedef('_CheckExceptionFn', () => dart.functionType(core.bool, [dart.dynamic]));
- const _Nullary = dart.typedef('_Nullary', () => dart.functionType(dart.dynamic, []));
- class ExpectException extends core.Object {
+ };
+ dart.fn(expect._identical, core.bool, [dart.dynamic, dart.dynamic]);
+ expect._CheckExceptionFn = dart.typedef('_CheckExceptionFn', () => dart.functionType(core.bool, [dart.dynamic]));
+ expect._Nullary = dart.typedef('_Nullary', () => dart.functionType(dart.dynamic, []));
+ expect.ExpectException = class ExpectException extends core.Object {
ExpectException(message) {
this.message = message;
}
toString() {
return this.message;
}
- }
- ExpectException[dart.implements] = () => [core.Exception];
- dart.setSignature(ExpectException, {
- constructors: () => ({ExpectException: [ExpectException, [core.String]]})
+ };
+ expect.ExpectException[dart.implements] = () => [core.Exception];
+ dart.setSignature(expect.ExpectException, {
+ constructors: () => ({ExpectException: [expect.ExpectException, [core.String]]})
});
- class NoInline extends core.Object {
+ expect.NoInline = class NoInline extends core.Object {
NoInline() {
}
- }
- dart.setSignature(NoInline, {
- constructors: () => ({NoInline: [NoInline, []]})
+ };
+ dart.setSignature(expect.NoInline, {
+ constructors: () => ({NoInline: [expect.NoInline, []]})
});
- class TrustTypeAnnotations extends core.Object {
+ expect.TrustTypeAnnotations = class TrustTypeAnnotations extends core.Object {
TrustTypeAnnotations() {
}
- }
- dart.setSignature(TrustTypeAnnotations, {
- constructors: () => ({TrustTypeAnnotations: [TrustTypeAnnotations, []]})
+ };
+ dart.setSignature(expect.TrustTypeAnnotations, {
+ constructors: () => ({TrustTypeAnnotations: [expect.TrustTypeAnnotations, []]})
});
- class AssumeDynamic extends core.Object {
+ expect.AssumeDynamic = class AssumeDynamic extends core.Object {
AssumeDynamic() {
}
- }
- dart.setSignature(AssumeDynamic, {
- constructors: () => ({AssumeDynamic: [AssumeDynamic, []]})
+ };
+ dart.setSignature(expect.AssumeDynamic, {
+ constructors: () => ({AssumeDynamic: [expect.AssumeDynamic, []]})
});
// Exports:
- exports.Expect = Expect;
- exports.ExpectException = ExpectException;
- exports.NoInline = NoInline;
- exports.TrustTypeAnnotations = TrustTypeAnnotations;
- exports.AssumeDynamic = AssumeDynamic;
+ exports.expect = expect;
});
« no previous file with comments | « test/codegen/expect/es6_modules.txt ('k') | test/codegen/expect/expect.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698