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

Unified Diff: pkg/dev_compiler/lib/js/common/dart_sdk.js

Side-by-side diff isn't available for this file because of its large size.
Issue 2568313002: Implement messages in assert() in dev_compiler. (Closed)
Patch Set: Format. Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
Download patch
« no previous file with comments | « pkg/dev_compiler/lib/js/amd/dart_sdk.js ('k') | pkg/dev_compiler/lib/js/es6/dart_sdk.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/dev_compiler/lib/js/common/dart_sdk.js
diff --git a/pkg/dev_compiler/lib/js/common/dart_sdk.js b/pkg/dev_compiler/lib/js/common/dart_sdk.js
index 7d85febacc2c5802c7235745daf1dba419a8e865..cde659e36416526e29737d05b41e07782059e3f2 100644
--- a/pkg/dev_compiler/lib/js/common/dart_sdk.js
+++ b/pkg/dev_compiler/lib/js/common/dart_sdk.js
@@ -1532,9 +1532,13 @@
debugger;
dart.throw(new core.UnimplementedError(message));
};
- dart.throwAssertionError = function() {
- debugger;
- dart.throw(new core.AssertionError());
+ dart.throwAssertionError = function(message) {
+ if (message === void 0) message = null;
+ return (() => {
+ debugger;
+ let error = message != null ? new _js_helper.AssertionErrorWithMessage(message()) : new core.AssertionError();
+ dart.throw(error);
+ })();
};
dart.throwNullValueError = function() {
debugger;
@@ -1895,8 +1899,11 @@
return map;
})();
};
- dart.assert = function(condition) {
- if (!condition) dart.throwAssertionError();
+ dart.assert = function(condition, message) {
+ if (message === void 0) message = null;
+ return (() => {
+ if (!condition) dart.throwAssertionError(message);
+ })();
};
dart.throw = function(obj) {
dart._stack = new Error();
@@ -11879,6 +11886,30 @@
constructors: () => ({new: dart.definiteFunctionType(_js_helper.RuntimeError, [dart.dynamic])}),
fields: () => ({message: dart.dynamic})
});
+ core.AssertionError = class AssertionError extends core.Error {
+ new() {
+ super.new();
+ }
+ toString() {
+ return "Assertion failed";
+ }
+ };
+ dart.setSignature(core.AssertionError, {
+ constructors: () => ({new: dart.definiteFunctionType(core.AssertionError, [])})
+ });
+ _js_helper.AssertionErrorWithMessage = class AssertionErrorWithMessage extends core.AssertionError {
+ new(message) {
+ this[_message] = message;
+ super.new();
+ }
+ toString() {
+ return dart.str`Assertion failed: ${this[_message]}`;
+ }
+ };
+ dart.setSignature(_js_helper.AssertionErrorWithMessage, {
+ constructors: () => ({new: dart.definiteFunctionType(_js_helper.AssertionErrorWithMessage, [core.Object])}),
+ fields: () => ({[_message]: core.Object})
+ });
_js_helper.random64 = function() {
let int32a = Math.random() * 0x100000000 >>> 0;
let int32b = Math.random() * 0x100000000 >>> 0;
@@ -12009,17 +12040,6 @@
return SyncIterable;
});
_js_helper.SyncIterable = SyncIterable();
- core.AssertionError = class AssertionError extends core.Error {
- new() {
- super.new();
- }
- toString() {
- return "Assertion failed";
- }
- };
- dart.setSignature(core.AssertionError, {
- constructors: () => ({new: dart.definiteFunctionType(core.AssertionError, [])})
- });
_js_helper.BooleanConversionAssertionError = class BooleanConversionAssertionError extends core.AssertionError {
new() {
super.new();
« no previous file with comments | « pkg/dev_compiler/lib/js/amd/dart_sdk.js ('k') | pkg/dev_compiler/lib/js/es6/dart_sdk.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698