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

Side by Side Diff: test/browser/runtime_tests.js

Issue 1245023004: fixes dart.throw to work for non-objects (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 5 years, 5 months 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
« lib/runtime/_operations.js ('K') | « lib/runtime/_operations.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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 var assert = chai.assert; 5 var assert = chai.assert;
6 var core = dart_library.import('dart/core'); 6 var core = dart_library.import('dart/core');
7 var collection = dart_library.import('dart/collection'); 7 var collection = dart_library.import('dart/collection');
8 var dart = dart_library.import('dart_runtime/dart'); 8 var dart = dart_library.import('dart_runtime/dart');
9 var dartx = dart.dartx; 9 var dartx = dart.dartx;
10 10
11 // TODO(leafp): These are here to test some things not 11 // TODO(leafp): These are here to test some things not
12 // currently exposed through the main dart entry point. 12 // currently exposed through the main dart entry point.
13 // If we decide to expose them, this can go away. 13 // If we decide to expose them, this can go away.
14 var classes = dart_library.import('dart_runtime/_classes'); 14 var classes = dart_library.import('dart_runtime/_classes');
15 var types = dart_library.import('dart_runtime/_types'); 15 var types = dart_library.import('dart_runtime/_types');
16 16
17 suite('generic', () => { 17 suite('generic', () => {
18 "use strict"; 18 "use strict";
19 19
20 let generic = dart.generic; 20 let generic = dart.generic;
21 21
22 test('zero arguments is not allowed', () => { 22 test('zero arguments is not allowed', () => {
23 assert.throws(() => { generic(function(){}); }); 23 assert.throws(() => { generic(function(){}); });
24 }); 24 });
25 25
26 test('can throw number', () => {
27 try {
28 dart.throw(42);
29 } catch (e) {
30 assert.equal(e, 42);
31 }
32 });
33
26 test('argument count cannot change', () => { 34 test('argument count cannot change', () => {
27 let SomeType = generic(function(x) { return {x: x}; }); 35 let SomeType = generic(function(x) { return {x: x}; });
28 assert.throws(() => { SomeType(1,2) }); 36 assert.throws(() => { SomeType(1,2) });
29 let obj = {}; 37 let obj = {};
30 assert.equal(SomeType(obj).x, obj); 38 assert.equal(SomeType(obj).x, obj);
31 assert.equal(SomeType(obj).x, obj); 39 assert.equal(SomeType(obj).x, obj);
32 assert.equal(SomeType().x, dart.dynamic); 40 assert.equal(SomeType().x, dart.dynamic);
33 }); 41 });
34 42
35 test('undefined/null are not allowed', () => { 43 test('undefined/null are not allowed', () => {
(...skipping 693 matching lines...) Expand 10 before | Expand all | Expand 10 after
729 737
730 suite('primitives', function() { 738 suite('primitives', function() {
731 'use strict'; 739 'use strict';
732 740
733 test('fixed length list', () => { 741 test('fixed length list', () => {
734 let list = new core.List(10); 742 let list = new core.List(10);
735 list[0] = 42; 743 list[0] = 42;
736 assert.throws(() => list.add(42)); 744 assert.throws(() => list.add(42));
737 }); 745 });
738 }); 746 });
OLDNEW
« lib/runtime/_operations.js ('K') | « lib/runtime/_operations.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698