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

Side by Side Diff: runtime/vm/intermediate_language_test.cc

Issue 10829451: Make Value not a subclass of Computation. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: rebased Created 8 years, 4 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 // 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 #include "vm/intermediate_language.h" 5 #include "vm/intermediate_language.h"
6 #include "vm/unit_test.h" 6 #include "vm/unit_test.h"
7 7
8 namespace dart { 8 namespace dart {
9 9
10 TEST_CASE(InstructionTests) { 10 TEST_CASE(InstructionTests) {
(...skipping 18 matching lines...) Expand all
29 EXPECT(def1->use_list()->next_use()->next_use() == NULL); 29 EXPECT(def1->use_list()->next_use()->next_use() == NULL);
30 UseVal* use3 = new UseVal(def1); 30 UseVal* use3 = new UseVal(def1);
31 EXPECT(def1->use_list()->next_use()->next_use()->next_use() == NULL); 31 EXPECT(def1->use_list()->next_use()->next_use()->next_use() == NULL);
32 use1->RemoveFromUseList(); 32 use1->RemoveFromUseList();
33 EXPECT(def1->use_list()->next_use()->next_use() == NULL); 33 EXPECT(def1->use_list()->next_use()->next_use() == NULL);
34 use3->SetDefinition(def2); 34 use3->SetDefinition(def2);
35 EXPECT(def1->use_list() == use2); 35 EXPECT(def1->use_list() == use2);
36 EXPECT(def1->use_list()->next_use() == NULL); 36 EXPECT(def1->use_list()->next_use() == NULL);
37 EXPECT(def2->use_list() == use3); 37 EXPECT(def2->use_list() == use3);
38 EXPECT(def2->use_list()->next_use() == NULL); 38 EXPECT(def2->use_list()->next_use() == NULL);
39 BindInstr* bind = new BindInstr(BindInstr::kUsed, use2); 39 BindInstr* bind =
40 new BindInstr(BindInstr::kUsed, new BooleanNegateComp(use2));
40 bind->RemoveInputUses(); 41 bind->RemoveInputUses();
41 EXPECT(def1->use_list() == NULL); 42 EXPECT(def1->use_list() == NULL);
42 // Test replacing with a definition without uses. 43 // Test replacing with a definition without uses.
43 UseVal* use4 = new UseVal(def2); 44 UseVal* use4 = new UseVal(def2);
44 def2->ReplaceUsesWith(def1); 45 def2->ReplaceUsesWith(def1);
45 EXPECT(def1->use_list() == use4); 46 EXPECT(def1->use_list() == use4);
46 EXPECT(def2->use_list() == NULL); 47 EXPECT(def2->use_list() == NULL);
47 EXPECT(use4->definition() == def1); 48 EXPECT(use4->definition() == def1);
48 } 49 }
49 50
50 TEST_CASE(OptimizationTests) { 51 TEST_CASE(OptimizationTests) {
51 Definition* def1 = new PhiInstr(0); 52 Definition* def1 = new PhiInstr(0);
52 Definition* def2 = new PhiInstr(0); 53 Definition* def2 = new PhiInstr(0);
53 UseVal* use1a = new UseVal(def1); 54 UseVal* use1a = new UseVal(def1);
54 UseVal* use1b = new UseVal(def1); 55 UseVal* use1b = new UseVal(def1);
55 EXPECT(use1a->Equals(use1b)); 56 EXPECT(use1a->Equals(use1b));
56 EXPECT(use1a->Hashcode() == use1b->Hashcode());
57 UseVal* use2 = new UseVal(def2); 57 UseVal* use2 = new UseVal(def2);
58 EXPECT(!use2->Equals(use1a)); 58 EXPECT(!use2->Equals(use1a));
59 59
60 ConstantVal* c1 = new ConstantVal(Bool::ZoneHandle(Bool::True())); 60 ConstantVal* c1 = new ConstantVal(Bool::ZoneHandle(Bool::True()));
61 ConstantVal* c2 = new ConstantVal(Bool::ZoneHandle(Bool::True())); 61 ConstantVal* c2 = new ConstantVal(Bool::ZoneHandle(Bool::True()));
62 EXPECT(c1->Equals(c2)); 62 EXPECT(c1->Equals(c2));
63 ConstantVal* c3 = new ConstantVal(Object::ZoneHandle()); 63 ConstantVal* c3 = new ConstantVal(Object::ZoneHandle());
64 ConstantVal* c4 = new ConstantVal(Object::ZoneHandle()); 64 ConstantVal* c4 = new ConstantVal(Object::ZoneHandle());
65 EXPECT(c3->Equals(c4)); 65 EXPECT(c3->Equals(c4));
66 EXPECT(!c3->Equals(c1)); 66 EXPECT(!c3->Equals(c1));
67 } 67 }
68 68
69 } // namespace dart 69 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698