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

Side by Side Diff: runtime/vm/snapshot_test.dart

Issue 11361190: a === b -> identical(a, b) (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments. Created 8 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/tests/vm/dart/isolate_mirror_local_test.dart ('k') | samples/swarm/App.dart » ('j') | 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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 import 'dart:isolate'; 5 import 'dart:isolate';
6 6
7 class Fields { 7 class Fields {
8 Fields(int i, int j) : fld1 = i, fld2 = j, fld5 = true {} 8 Fields(int i, int j) : fld1 = i, fld2 = j, fld5 = true {}
9 int fld1; 9 int fld1;
10 final int fld2; 10 final int fld2;
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 } 108 }
109 109
110 void build(int pile, int disks) { 110 void build(int pile, int disks) {
111 for (var i = disks - 1; i >= 0; i--) { 111 for (var i = disks - 1; i >= 0; i--) {
112 push(pile, new TowersDisk(i)); 112 push(pile, new TowersDisk(i));
113 } 113 }
114 } 114 }
115 115
116 void push(int pile, TowersDisk disk) { 116 void push(int pile, TowersDisk disk) {
117 TowersDisk top = piles[pile]; 117 TowersDisk top = piles[pile];
118 if ((top !== null) && (disk.size >= top.size)) 118 if ((top != null) && (disk.size >= top.size))
119 Error.error("Cannot put a big disk on a smaller disk."); 119 Error.error("Cannot put a big disk on a smaller disk.");
120 disk.next = top; 120 disk.next = top;
121 piles[pile] = disk; 121 piles[pile] = disk;
122 } 122 }
123 123
124 TowersDisk pop(int pile) { 124 TowersDisk pop(int pile) {
125 var top = piles[pile]; 125 var top = piles[pile];
126 if (top === null) 126 if (top == null)
127 Error.error("Attempting to remove a disk from an empty pile."); 127 Error.error("Attempting to remove a disk from an empty pile.");
128 piles[pile] = top.next; 128 piles[pile] = top.next;
129 top.next = null; 129 top.next = null;
130 return top; 130 return top;
131 } 131 }
132 132
133 void moveTop(int from, int to) { 133 void moveTop(int from, int to) {
134 push(to, pop(from)); 134 push(to, pop(from));
135 movesDone++; 135 movesDone++;
136 } 136 }
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after
519 // T r e e S o r t 519 // T r e e S o r t
520 class TreeNodePress { 520 class TreeNodePress {
521 int value; 521 int value;
522 TreeNodePress left; 522 TreeNodePress left;
523 TreeNodePress right; 523 TreeNodePress right;
524 524
525 TreeNodePress(int n) : value = n {} 525 TreeNodePress(int n) : value = n {}
526 526
527 void insert(int n) { 527 void insert(int n) {
528 if (n < value) { 528 if (n < value) {
529 if (left === null) left = new TreeNodePress(n); 529 if (left == null) left = new TreeNodePress(n);
530 else left.insert(n); 530 else left.insert(n);
531 } else { 531 } else {
532 if (right === null) right = new TreeNodePress(n); 532 if (right == null) right = new TreeNodePress(n);
533 else right.insert(n); 533 else right.insert(n);
534 } 534 }
535 } 535 }
536 536
537 void check() { 537 void check() {
538 TreeNodePress left = this.left; 538 TreeNodePress left = this.left;
539 TreeNodePress right = this.right; 539 TreeNodePress right = this.right;
540 int value = this.value; 540 int value = this.value;
541 541
542 return ((left === null) || ((left.value < value) && left.check())) && 542 return ((left == null) || ((left.value < value) && left.check())) &&
543 ((right === null) || ((right.value >= value) && right.check())); 543 ((right == null) || ((right.value >= value) && right.check()));
544 } 544 }
545 } 545 }
546 546
547 class TreeSort { 547 class TreeSort {
548 static void sort(List<int> a) { 548 static void sort(List<int> a) {
549 int len = a.length; 549 int len = a.length;
550 TreeNodePress tree = new TreeNodePress(a[0]); 550 TreeNodePress tree = new TreeNodePress(a[0]);
551 for (var i = 1; i < len; i++) tree.insert(a[i]); 551 for (var i = 1; i < len; i++) tree.insert(a[i]);
552 if (!tree.check()) Error.error("Invalid result, tree not sorted"); 552 if (!tree.check()) Error.error("Invalid result, tree not sorted");
553 } 553 }
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
603 this.next = next; 603 this.next = next;
604 604
605 static ListElement makeList(int length) { 605 static ListElement makeList(int length) {
606 if (length == 0) return null; 606 if (length == 0) return null;
607 return new ListElement(length, makeList(length - 1)); 607 return new ListElement(length, makeList(length - 1));
608 } 608 }
609 609
610 static bool isShorter(ListElement x, ListElement y) { 610 static bool isShorter(ListElement x, ListElement y) {
611 ListElement xTail = x; 611 ListElement xTail = x;
612 ListElement yTail = y; 612 ListElement yTail = y;
613 while (yTail !== null) { 613 while (yTail != null) {
614 if (xTail === null) return true; 614 if (xTail == null) return true;
615 xTail = xTail.next; 615 xTail = xTail.next;
616 yTail = yTail.next; 616 yTail = yTail.next;
617 } 617 }
618 return false; 618 return false;
619 } 619 }
620 } 620 }
621 621
622 class Takl { 622 class Takl {
623 static ListElement takl(ListElement x, ListElement y, ListElement z) { 623 static ListElement takl(ListElement x, ListElement y, ListElement z) {
624 if (ListElement.isShorter(y, x)) { 624 if (ListElement.isShorter(y, x)) {
(...skipping 695 matching lines...) Expand 10 before | Expand all | Expand 10 after
1320 List sendObject = new List(5); 1320 List sendObject = new List(5);
1321 sendObject[0] = local_list1; 1321 sendObject[0] = local_list1;
1322 sendObject[1] = sendObject; 1322 sendObject[1] = sendObject;
1323 sendObject[2] = local_list2; 1323 sendObject[2] = local_list2;
1324 sendObject[3] = sendObject; 1324 sendObject[3] = sendObject;
1325 sendObject[4] = local_list3; 1325 sendObject[4] = local_list3;
1326 remote.call(sendObject).then((var replyObject) { 1326 remote.call(sendObject).then((var replyObject) {
1327 Expect.equals(true, sendObject is List); 1327 Expect.equals(true, sendObject is List);
1328 Expect.equals(true, replyObject is List); 1328 Expect.equals(true, replyObject is List);
1329 Expect.equals(sendObject.length, replyObject.length); 1329 Expect.equals(sendObject.length, replyObject.length);
1330 Expect.equals(true, replyObject[1] === replyObject); 1330 Expect.equals(true, identical(replyObject[1], replyObject));
1331 Expect.equals(true, replyObject[3] === replyObject); 1331 Expect.equals(true, identical(replyObject[3], replyObject));
1332 Expect.equals(true, replyObject[0] === replyObject[2][1]); 1332 Expect.equals(true, identical(replyObject[0], replyObject[2][1]));
1333 Expect.equals(true, replyObject[0] === replyObject[2][2]); 1333 Expect.equals(true, identical(replyObject[0], replyObject[2][2]));
1334 Expect.equals(true, replyObject[2] === replyObject[4][0]); 1334 Expect.equals(true, identical(replyObject[2], replyObject[4][0]));
1335 Expect.equals(true, replyObject[0][0] === replyObject[0][2]); 1335 Expect.equals(true, identical(replyObject[0][0], replyObject[0][2]));
1336 // Bigint literals are not canonicalized so do a == check. 1336 // Bigint literals are not canonicalized so do a == check.
1337 Expect.equals(true, replyObject[0][3] == replyObject[4][4]); 1337 Expect.equals(true, replyObject[0][3] == replyObject[4][4]);
1338 }); 1338 });
1339 1339
1340 // Shutdown the MessageServer. 1340 // Shutdown the MessageServer.
1341 remote.call(-1).then(expectAsync1((int message) { 1341 remote.call(-1).then(expectAsync1((int message) {
1342 Expect.equals(MessageTest.elms.length + 1, message); 1342 Expect.equals(MessageTest.elms.length + 1, message);
1343 })); 1343 }));
1344 }); 1344 });
1345 } 1345 }
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
1447 _validated = new Completer<bool>(); 1447 _validated = new Completer<bool>();
1448 } 1448 }
1449 1449
1450 void startClient(int id) { 1450 void startClient(int id) {
1451 assert(_sent < N); 1451 assert(_sent < N);
1452 final client = new LineProcessorClient(this, id); 1452 final client = new LineProcessorClient(this, id);
1453 client.processLine(_sent++); 1453 client.processLine(_sent++);
1454 } 1454 }
1455 1455
1456 void notifyProcessedLine(LineProcessorClient client, int y, List<int> line) { 1456 void notifyProcessedLine(LineProcessorClient client, int y, List<int> line) {
1457 assert(_result[y] === null); 1457 assert(_result[y] == null);
1458 _result[y] = line; 1458 _result[y] = line;
1459 _lineProcessedBy[y] = client; 1459 _lineProcessedBy[y] = client;
1460 1460
1461 if (_sent != N) { 1461 if (_sent != N) {
1462 client.processLine(_sent++); 1462 client.processLine(_sent++);
1463 } else { 1463 } else {
1464 client.shutdown(); 1464 client.shutdown();
1465 } 1465 }
1466 1466
1467 // If all lines have been computed, validate the result. 1467 // If all lines have been computed, validate the result.
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
1548 void processLines() { 1548 void processLines() {
1549 port.receive((message, SendPort replyTo) { 1549 port.receive((message, SendPort replyTo) {
1550 if (message == TERMINATION_MESSAGE) { 1550 if (message == TERMINATION_MESSAGE) {
1551 assert(replyTo == null); 1551 assert(replyTo == null);
1552 port.close(); 1552 port.close();
1553 } else { 1553 } else {
1554 replyTo.send(processLine(message), null); 1554 replyTo.send(processLine(message), null);
1555 } 1555 }
1556 }); 1556 });
1557 } 1557 }
OLDNEW
« no previous file with comments | « runtime/tests/vm/dart/isolate_mirror_local_test.dart ('k') | samples/swarm/App.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698