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

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

Issue 2568313002: Implement messages in assert() in dev_compiler. (Closed)
Patch Set: 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
Index: pkg/dev_compiler/lib/js/legacy/dart_sdk.js
diff --git a/pkg/dev_compiler/lib/js/legacy/dart_sdk.js b/pkg/dev_compiler/lib/js/legacy/dart_sdk.js
index 150f4405e62acd30d7b5aeb439aa4e4ddf81f8ab..7092d681cf8525d757cc630f8db4c259c5ba0a85 100644
--- a/pkg/dev_compiler/lib/js/legacy/dart_sdk.js
+++ b/pkg/dev_compiler/lib/js/legacy/dart_sdk.js
@@ -1537,6 +1537,10 @@ dart_library.library('dart_sdk', null, /* Imports */[
debugger;
dart.throw(new core.AssertionError());
};
+ dart.throwAssertionErrorWithMessage = function(message) {
+ debugger;
+ dart.throw(new _js_helper.AssertionErrorWithMessage(message));
+ };
dart.throwNullValueError = function() {
debugger;
dart.throw(new core.NoSuchMethodError(null, new core.Symbol('<Unexpected Null Value>'), null, null, null));
@@ -1899,6 +1903,9 @@ dart_library.library('dart_sdk', null, /* Imports */[
dart.assert = function(condition) {
if (!condition) dart.throwAssertionError();
};
+ dart.assertMessage = function(condition, message) {
+ if (!condition) dart.throwAssertionErrorWithMessage(message());
+ };
dart.throw = function(obj) {
dart._stack = new Error();
throw obj;
@@ -11880,6 +11887,30 @@ dart_library.library('dart_sdk', null, /* Imports */[
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;
@@ -12010,17 +12041,6 @@ dart_library.library('dart_sdk', null, /* Imports */[
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();

Powered by Google App Engine
This is Rietveld 408576698