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

Unified Diff: frog/corejs.dart

Issue 8534001: Adds typechecking of return values (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: better runtime checks Created 9 years, 1 month 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 | « no previous file | frog/frogsh » ('j') | frog/lib/corelib_impl.dart » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: frog/corejs.dart
diff --git a/frog/corejs.dart b/frog/corejs.dart
index bfa0875c0f5ce9743452b5d5b8df3510cad661b7..4b58b2e3d0c00d9f481f4894655223a7f861fd6c 100644
--- a/frog/corejs.dart
+++ b/frog/corejs.dart
@@ -287,12 +287,10 @@ function $toDartException(e) {
if (useNotNullBool) {
useThrow = true;
+ // Some testing showed that this patterned fared well across browsers.
w.writeln(@"""
function $notnull_bool(test) {
- if (test == null || typeof(test) != 'boolean') {
- $throw(new TypeError('must be "true" or "false"'));
- }
- return test === true;
+ return typeof(test) == 'boolean' ? test : test.is$bool();
}""");
}
« no previous file with comments | « no previous file | frog/frogsh » ('j') | frog/lib/corelib_impl.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698