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

Side by Side Diff: pkg/dev_compiler/tool/input_sdk/private/js_helper.dart

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:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library dart._js_helper; 5 library dart._js_helper;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 8
9 import 'dart:_foreign_helper' show 9 import 'dart:_foreign_helper' show
10 JS, 10 JS,
(...skipping 833 matching lines...) Expand 10 before | Expand all | Expand 10 after
844 /** 844 /**
845 * Error thrown when a runtime error occurs. 845 * Error thrown when a runtime error occurs.
846 */ 846 */
847 class RuntimeError extends Error { 847 class RuntimeError extends Error {
848 final message; 848 final message;
849 RuntimeError(this.message); 849 RuntimeError(this.message);
850 String toString() => "RuntimeError: $message"; 850 String toString() => "RuntimeError: $message";
851 } 851 }
852 852
853 /** 853 /**
854 * Error thrown when an assert() fails with a message:
855 *
856 * assert(false, "Message here");
857 */
858 class AssertionErrorWithMessage extends AssertionError {
859 final Object _message;
860 AssertionErrorWithMessage(this._message);
861 String toString() => "Assertion failed: ${_message}";
862 }
863
864 /**
854 * Creates a random number with 64 bits of randomness. 865 * Creates a random number with 64 bits of randomness.
855 * 866 *
856 * This will be truncated to the 53 bits available in a double. 867 * This will be truncated to the 53 bits available in a double.
857 */ 868 */
858 int random64() { 869 int random64() {
859 // TODO(lrn): Use a secure random source. 870 // TODO(lrn): Use a secure random source.
860 int int32a = JS("int", "(Math.random() * 0x100000000) >>> 0"); 871 int int32a = JS("int", "(Math.random() * 0x100000000) >>> 0");
861 int int32b = JS("int", "(Math.random() * 0x100000000) >>> 0"); 872 int int32b = JS("int", "(Math.random() * 0x100000000) >>> 0");
862 return int32a + int32b * 0x100000000; 873 return int32a + int32b * 0x100000000;
863 } 874 }
(...skipping 30 matching lines...) Expand all
894 // we have no way of telling the compiler yet, so it will generate an extra 905 // we have no way of telling the compiler yet, so it will generate an extra
895 // layer of indirection that wraps the SyncIterator. 906 // layer of indirection that wraps the SyncIterator.
896 _jsIterator() => JS('', '#(...#)', _generator, _args); 907 _jsIterator() => JS('', '#(...#)', _generator, _args);
897 908
898 Iterator<E> get iterator => new SyncIterator<E>(_jsIterator()); 909 Iterator<E> get iterator => new SyncIterator<E>(_jsIterator());
899 } 910 }
900 911
901 class BooleanConversionAssertionError extends AssertionError { 912 class BooleanConversionAssertionError extends AssertionError {
902 toString() => 'Failed assertion: boolean expression must not be null'; 913 toString() => 'Failed assertion: boolean expression must not be null';
903 } 914 }
OLDNEW
« no previous file with comments | « pkg/dev_compiler/tool/input_sdk/private/ddc_runtime/runtime.dart ('k') | tests/language_strong/assert_with_message_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698