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

Side by Side Diff: tests/html/native_gc_test.dart

Issue 12328104: Change new List(n) to return fixed length list. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Merge to head. Created 7 years, 9 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 | Annotate | Revision Log
OLDNEW
1 library NativeGCTest; 1 library NativeGCTest;
2 import '../../pkg/unittest/lib/unittest.dart'; 2 import '../../pkg/unittest/lib/unittest.dart';
3 import '../../pkg/unittest/lib/html_config.dart'; 3 import '../../pkg/unittest/lib/html_config.dart';
4 import 'dart:html'; 4 import 'dart:html';
5 5
6 var testEvent = new EventStreamProvider<Event>('test'); 6 var testEvent = new EventStreamProvider<Event>('test');
7 7
8 main() { 8 main() {
9 useHtmlConfiguration(); 9 useHtmlConfiguration();
10 10
11 test('EventListener', () { 11 test('EventListener', () {
12 final int N = 1000000; 12 final int N = 1000000;
13 final int M = 1000; 13 final int M = 1000;
14 14
15 var div; 15 var div;
16 for (int i = 0; i < M; ++i) { 16 for (int i = 0; i < M; ++i) {
17 // This memory should be freed when the listener below is 17 // This memory should be freed when the listener below is
18 // collected. 18 // collected.
19 List l = new List.fixedLength(N); 19 List l = new List(N);
20 20
21 // Record the iteration number. 21 // Record the iteration number.
22 l[N - 1] = i; 22 l[N - 1] = i;
23 23
24 div = new Element.tag('div'); 24 div = new Element.tag('div');
25 testEvent.forTarget(div).listen((_) { 25 testEvent.forTarget(div).listen((_) {
26 // Only the final iteration's listener should be invoked. 26 // Only the final iteration's listener should be invoked.
27 // Note: the reference to l keeps the entire list alive. 27 // Note: the reference to l keeps the entire list alive.
28 expect(l[N - 1], M - 1); 28 expect(l[N - 1], M - 1);
29 }); 29 });
(...skipping 16 matching lines...) Expand all
46 for (int i = 0; i < 100; ++i) { 46 for (int i = 0; i < 100; ++i) {
47 triggerMajorGC(); 47 triggerMajorGC();
48 } 48 }
49 49
50 testDiv.onClick.listen(expectAsync1((e) {})); 50 testDiv.onClick.listen(expectAsync1((e) {}));
51 window.postMessage(message, '*'); 51 window.postMessage(message, '*');
52 }); 52 });
53 } 53 }
54 54
55 void triggerMajorGC() { 55 void triggerMajorGC() {
56 List list = new List.fixedLength(1000000); 56 List list = new List(1000000);
57 Element div = new DivElement(); 57 Element div = new DivElement();
58 div.onClick.listen((e) => print(list[0])); 58 div.onClick.listen((e) => print(list[0]));
59 } 59 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698