Skip to content

Commit

Permalink
fixes #175, fixed arrays
Browse files Browse the repository at this point in the history
R=vsm@google.com

Review URL: https://codereview.chromium.org/1138533003
  • Loading branch information
John Messerly committed May 8, 2015
1 parent da20815 commit ef8edb1
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 3 deletions.
3 changes: 2 additions & 1 deletion pkg/dev_compiler/lib/runtime/dart_runtime.js
Original file line number Diff line number Diff line change
Expand Up @@ -967,7 +967,8 @@ var dart, _js_helper, _js_primitives;
dart.JsSymbol = Symbol;

function import_(value) {
if (!value) throw 'missing required module';
// TODO(jmesserly): throw once we're loading all of core libs.
if (!value && console) console.warn('missing required module');
return value;
}
dart.import = import_;
Expand Down
10 changes: 10 additions & 0 deletions pkg/dev_compiler/test/browser/runtime_tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -391,3 +391,13 @@ suite('instanceOf', () => {
assert.equal(intType, core.int);
});
});

suite('primitives', function() {
'use strict';

test('fixed length list', () => {
let list = new core.List(10);
list[0] = 42;
assert.throws(() => list.add(42));
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class JSArray<E> implements List<E>, JSIndexable {
}

checkGrowable(reason) {
if (this is !JSExtendableArray) {
if (JS('bool', r'#.fixed$length', this)) {
throw new UnsupportedError(reason);
}
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/dev_compiler/tool/input_sdk/private/js_array.dart
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class JSArray<E> implements List<E>, JSIndexable {
}

checkGrowable(reason) {
if (this is !JSExtendableArray) {
if (JS('bool', r'#.fixed$length', this)) {
throw new UnsupportedError(reason);
}
}
Expand Down

0 comments on commit ef8edb1

Please sign in to comment.