dart-sdk/runtime/vm/intermediate_language_test.cc
vegorov@google.com 1acb21443f Consolidate all range analysis related code in a separate file.
This makes working with it easier, similar to how we have all type propagation code in flow_graph_type_propagator.{cc,h}

BUG=
R=fschneider@google.com

Review URL: https://codereview.chromium.org//442293002

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@38928 260f80e4-7a28-3924-810f-c04153c831b5
2014-08-06 12:43:49 +00:00

44 lines
1.3 KiB
C++

// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
#include "vm/intermediate_language.h"
#include "vm/unit_test.h"
namespace dart {
TEST_CASE(InstructionTests) {
TargetEntryInstr* target_instr =
new TargetEntryInstr(1, CatchClauseNode::kInvalidTryIndex);
EXPECT(target_instr->IsBlockEntry());
EXPECT(!target_instr->IsDefinition());
CurrentContextInstr* context = new CurrentContextInstr();
EXPECT(context->IsDefinition());
EXPECT(!context->IsBlockEntry());
}
TEST_CASE(OptimizationTests) {
JoinEntryInstr* join =
new JoinEntryInstr(1, CatchClauseNode::kInvalidTryIndex);
Definition* def1 = new PhiInstr(join, 0);
Definition* def2 = new PhiInstr(join, 0);
Value* use1a = new Value(def1);
Value* use1b = new Value(def1);
EXPECT(use1a->Equals(use1b));
Value* use2 = new Value(def2);
EXPECT(!use2->Equals(use1a));
ConstantInstr* c1 = new ConstantInstr(Bool::True());
ConstantInstr* c2 = new ConstantInstr(Bool::True());
EXPECT(c1->Equals(c2));
ConstantInstr* c3 = new ConstantInstr(Object::ZoneHandle());
ConstantInstr* c4 = new ConstantInstr(Object::ZoneHandle());
EXPECT(c3->Equals(c4));
EXPECT(!c3->Equals(c1));
}
} // namespace dart