| OLD | NEW |
| 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 29 matching lines...) Expand all Loading... |
| 40 bind->RemoveInputUses(); | 40 bind->RemoveInputUses(); |
| 41 EXPECT(def1->use_list() == NULL); | 41 EXPECT(def1->use_list() == NULL); |
| 42 // Test replacing with a definition without uses. | 42 // Test replacing with a definition without uses. |
| 43 UseVal* use4 = new UseVal(def2); | 43 UseVal* use4 = new UseVal(def2); |
| 44 def2->ReplaceUsesWith(def1); | 44 def2->ReplaceUsesWith(def1); |
| 45 EXPECT(def1->use_list() == use4); | 45 EXPECT(def1->use_list() == use4); |
| 46 EXPECT(def2->use_list() == NULL); | 46 EXPECT(def2->use_list() == NULL); |
| 47 EXPECT(use4->definition() == def1); | 47 EXPECT(use4->definition() == def1); |
| 48 } | 48 } |
| 49 | 49 |
| 50 TEST_CASE(OptimizationTests) { |
| 51 Definition* def1 = new PhiInstr(0); |
| 52 Definition* def2 = new PhiInstr(0); |
| 53 UseVal* use1a = new UseVal(def1); |
| 54 UseVal* use1b = new UseVal(def1); |
| 55 EXPECT(use1a->Equals(use1b)); |
| 56 EXPECT(use1a->Hashcode() == use1b->Hashcode()); |
| 57 UseVal* use2 = new UseVal(def2); |
| 58 EXPECT(!use2->Equals(use1a)); |
| 59 |
| 60 ConstantVal* c1 = new ConstantVal(Bool::ZoneHandle(Bool::True())); |
| 61 ConstantVal* c2 = new ConstantVal(Bool::ZoneHandle(Bool::True())); |
| 62 EXPECT(c1->Equals(c2)); |
| 63 ConstantVal* c3 = new ConstantVal(Object::ZoneHandle()); |
| 64 ConstantVal* c4 = new ConstantVal(Object::ZoneHandle()); |
| 65 EXPECT(c3->Equals(c4)); |
| 66 EXPECT(!c3->Equals(c1)); |
| 67 } |
| 68 |
| 50 } // namespace dart | 69 } // namespace dart |
| OLD | NEW |