Commit ffa5e5fc authored by bradnelson's avatar bradnelson Committed by Commit bot

Refactor type collector testing macros.

Assume a zone is in scope instead of a handles object.
Move INT32_TYPE into test-typing-reset.
Provide a CHECK_SKIP() macro to allow skipping
sections of an ast expression walk.

BUG= https://code.google.com/p/v8/issues/detail?id=4203
TEST=test-typing-reset, test-ast-expression-visitor
R=rossberg@chromium.org,titzer@chromium.org
LOG=N

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

Cr-Commit-Position: refs/heads/master@{#30484}
parent e5dbfd06
......@@ -14,17 +14,11 @@
CHECK_EQ(index, types.size()); \
}
#define DEFAULT_TYPE Bounds::Unbounded()
#define INT32_TYPE \
Bounds(Type::Signed32(handles.main_zone()), \
Type::Signed32(handles.main_zone()))
#define CHECK_EXPR(ekind, type) \
CHECK_LT(index, types.size()); \
CHECK(strcmp(#ekind, types[index].kind) == 0); \
CHECK_EQ(depth, types[index].depth); \
CHECK(type.lower->Is(types[index].bounds.lower)); \
CHECK(type.upper->Is(types[index].bounds.upper)); \
CHECK(types[index].bounds.Narrows(type)); \
for (int j = (++depth, ++index, 0); j < 1 ? 1 : (--depth, 0); ++j)
#define CHECK_VAR(vname, type) \
......@@ -33,4 +27,12 @@
types[index - 1].name->raw_data() + \
types[index - 1].name->byte_length()));
#define CHECK_SKIP() \
{ \
++index; \
while (index < types.size() && types[index].depth > depth) { \
++index; \
} \
}
#endif // V8_EXPRESSION_TYPE_COLLECTOR_MACROS_H_
This diff is collapsed.
......@@ -17,6 +17,8 @@
#include "test/cctest/expression-type-collector.h"
#include "test/cctest/expression-type-collector-macros.h"
#define INT32_TYPE Bounds(Type::Signed32(), Type::Signed32())
using namespace v8::internal;
namespace {
......@@ -27,14 +29,13 @@ class TypeSetter : public AstExpressionVisitor {
protected:
void VisitExpression(Expression* expression) {
expression->set_bounds(Bounds(Type::Integral32()));
expression->set_bounds(INT32_TYPE);
}
};
void CheckAllSame(ZoneVector<ExpressionTypeEntry>& types,
Bounds expected_type) {
HandleAndZoneScope handles;
CHECK_TYPES_BEGIN {
// function logSum
CHECK_EXPR(FunctionLiteral, expected_type) {
......@@ -283,7 +284,7 @@ TEST(ResetTypingInfo) {
// Core of the test.
ZoneVector<ExpressionTypeEntry> types(handles.main_zone());
ExpressionTypeCollector(&compilation_info, &types).Run();
CheckAllSame(types, DEFAULT_TYPE);
CheckAllSame(types, Bounds::Unbounded());
TypeSetter(&compilation_info).Run();
......@@ -293,5 +294,5 @@ TEST(ResetTypingInfo) {
TypingReseter(&compilation_info).Run();
ExpressionTypeCollector(&compilation_info, &types).Run();
CheckAllSame(types, DEFAULT_TYPE);
CheckAllSame(types, Bounds::Unbounded());
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment