Commit 8ddc260d authored by ulan's avatar ulan Committed by Commit bot

[parser, serializer] Fix more -Wsign-compare warnings.

BUG=v8:5614

Review-Url: https://codereview.chromium.org/2481013010
Cr-Commit-Position: refs/heads/master@{#40927}
parent 7b1a0484
......@@ -349,9 +349,9 @@ void Utf8ExternalStreamingStream::SearchPosition(size_t position) {
// No chunks. Fetch at least one, so we can assume !chunks_.empty() below.
if (chunks_.empty()) {
DCHECK_EQ(current_.chunk_no, 0);
DCHECK_EQ(current_.pos.bytes, 0);
DCHECK_EQ(current_.pos.chars, 0);
DCHECK_EQ(current_.chunk_no, 0u);
DCHECK_EQ(current_.pos.bytes, 0u);
DCHECK_EQ(current_.pos.chars, 0u);
FetchChunk();
}
......@@ -438,7 +438,8 @@ size_t Utf8ExternalStreamingStream::FillBuffer(size_t position) {
FillBufferFromCurrentChunk();
}
DCHECK_EQ(current_.pos.chars - position, buffer_end_ - buffer_cursor_);
DCHECK_EQ(current_.pos.chars - position,
static_cast<size_t>(buffer_end_ - buffer_cursor_));
return buffer_end_ - buffer_cursor_;
}
......@@ -497,7 +498,7 @@ size_t FindChunk(Chunks& chunks, ScriptCompiler::ExternalSourceStream* source_,
// let's look at chunks back-to-front.
size_t chunk_no = chunks.size() - 1;
while (chunks[chunk_no].byte_pos > position) {
DCHECK_NE(chunk_no, 0);
DCHECK_NE(chunk_no, 0u);
chunk_no--;
}
DCHECK_LE(chunks[chunk_no].byte_pos, position);
......@@ -593,7 +594,7 @@ bool TwoByteExternalStreamingStream::ReadBlock() {
// one_char_buffer_ to hold the full character.
bool lonely_byte = (chunks_[chunk_no].byte_pos == (2 * position + 1));
if (lonely_byte) {
DCHECK_NE(chunk_no, 0);
DCHECK_NE(chunk_no, 0u);
Chunk& previous_chunk = chunks_[chunk_no - 1];
#ifdef V8_TARGET_BIG_ENDIAN
uc16 character = current.data[0] |
......@@ -715,7 +716,7 @@ bool TwoByteExternalBufferedStream::ReadBlock() {
size_t TwoByteExternalBufferedStream::FillBuffer(size_t position,
size_t chunk_no) {
DCHECK_EQ(chunks_[chunk_no].byte_pos % 2, 1);
DCHECK_EQ(chunks_[chunk_no].byte_pos % 2, 1u);
bool odd_start = true;
// Align buffer_pos_ to the size of the buffer.
{
......@@ -738,7 +739,7 @@ size_t TwoByteExternalBufferedStream::FillBuffer(size_t position,
size_t totalLength = 0;
bool lonely_byte = (current->byte_pos == (2 * position + 1));
if (lonely_byte) {
DCHECK_NE(chunk_no, 0);
DCHECK_NE(chunk_no, 0u);
Chunk& previous_chunk = chunks_[chunk_no - 1];
*reinterpret_cast<uint8_t*>(buffer_) =
previous_chunk.data[previous_chunk.byte_length - 1];
......
......@@ -59,7 +59,7 @@ void Scanner::BookmarkScope::Apply() {
} else {
scanner_->SeekNext(bookmark_);
scanner_->Next();
DCHECK_EQ(scanner_->location().beg_pos, bookmark_);
DCHECK_EQ(scanner_->location().beg_pos, static_cast<int>(bookmark_));
}
bookmark_ = kBookmarkWasApplied;
}
......@@ -1638,7 +1638,7 @@ void Scanner::SeekNext(size_t position) {
// 3, re-scan, by scanning the look-ahead char + 1 token (next_).
c0_ = source_->Advance();
Next();
DCHECK_EQ(next_.location.beg_pos, position);
DCHECK_EQ(next_.location.beg_pos, static_cast<int>(position));
}
} // namespace internal
......
......@@ -346,7 +346,7 @@ uchar Utf8::ValueOfIncremental(byte next, Utf8IncrementalBuffer* buffer) {
} else {
// Otherwise, process the previous byte and save the next byte for next
// time.
DCHECK_EQ(0, *buffer);
DCHECK_EQ(0u, *buffer);
*buffer = next;
return t;
}
......
......@@ -1730,7 +1730,7 @@ static Maybe<bool> SetPropertiesFromKeyValuePairs(Isolate* isolate,
MaybeHandle<Object>
ValueDeserializer::ReadObjectUsingEntireBufferForLegacyFormat() {
DCHECK_EQ(version_, 0);
DCHECK_EQ(version_, 0u);
HandleScope scope(isolate_);
std::vector<Handle<Object>> stack;
while (position_ < end_) {
......
......@@ -6120,7 +6120,7 @@ TEST(ModuleParsingInternals) {
i::ModuleDescriptor* descriptor = module_scope->module();
CHECK_NOT_NULL(descriptor);
CHECK_EQ(5, descriptor->module_requests().size());
CHECK_EQ(5u, descriptor->module_requests().size());
for (const auto& elem : descriptor->module_requests()) {
if (elem.first->IsOneByteEqualTo("m.js"))
CHECK_EQ(elem.second, 0);
......@@ -6142,7 +6142,7 @@ TEST(ModuleParsingInternals) {
CheckEntry(descriptor->special_exports().at(2), "bb", nullptr, "aa",
0); // !!!
CHECK_EQ(8, descriptor->regular_exports().size());
CHECK_EQ(8u, descriptor->regular_exports().size());
entry = descriptor->regular_exports()
.find(declarations->AtForTest(3)->proxy()->raw_name())
->second;
......@@ -6169,7 +6169,7 @@ TEST(ModuleParsingInternals) {
CheckEntry(entry, "foob", "foob", nullptr, -1);
// TODO(neis): The next lines are terrible. Find a better way.
auto name_x = declarations->AtForTest(0)->proxy()->raw_name();
CHECK_EQ(2, descriptor->regular_exports().count(name_x));
CHECK_EQ(2u, descriptor->regular_exports().count(name_x));
auto it = descriptor->regular_exports().equal_range(name_x).first;
entry = it->second;
if (entry->export_name->IsOneByteEqualTo("y")) {
......@@ -6187,7 +6187,7 @@ TEST(ModuleParsingInternals) {
CheckEntry(descriptor->namespace_imports().at(1), nullptr, "foob", nullptr,
4);
CHECK_EQ(4, descriptor->regular_imports().size());
CHECK_EQ(4u, descriptor->regular_imports().size());
entry = descriptor->regular_imports()
.find(declarations->AtForTest(1)->proxy()->raw_name())
->second;
......
......@@ -1962,19 +1962,19 @@ TEST(SnapshotCreatorMultipleContexts) {
v8::Local<v8::Context> context = v8::Context::New(isolate);
v8::Context::Scope context_scope(context);
CompileRun("var f = function() { return 1; }");
CHECK_EQ(0, creator.AddContext(context));
CHECK_EQ(0u, creator.AddContext(context));
}
{
v8::HandleScope handle_scope(isolate);
v8::Local<v8::Context> context = v8::Context::New(isolate);
v8::Context::Scope context_scope(context);
CompileRun("var f = function() { return 2; }");
CHECK_EQ(1, creator.AddContext(context));
CHECK_EQ(1u, creator.AddContext(context));
}
{
v8::HandleScope handle_scope(isolate);
v8::Local<v8::Context> context = v8::Context::New(isolate);
CHECK_EQ(2, creator.AddContext(context));
CHECK_EQ(2u, creator.AddContext(context));
}
blob =
creator.CreateBlob(v8::SnapshotCreator::FunctionCodeHandling::kClear);
......@@ -2044,7 +2044,7 @@ TEST(SnapshotCreatorExternalReferences) {
callback->GetFunction(context).ToLocalChecked();
CHECK(context->Global()->Set(context, v8_str("f"), function).FromJust());
ExpectInt32("f()", 42);
CHECK_EQ(0, creator.AddContext(context));
CHECK_EQ(0u, creator.AddContext(context));
}
blob =
creator.CreateBlob(v8::SnapshotCreator::FunctionCodeHandling::kClear);
......@@ -2104,7 +2104,7 @@ TEST(SnapshotCreatorUnknownExternalReferences) {
CHECK(context->Global()->Set(context, v8_str("f"), function).FromJust());
ExpectInt32("f()", 42);
CHECK_EQ(0, creator.AddContext(context));
CHECK_EQ(0u, creator.AddContext(context));
}
v8::StartupData blob =
creator.CreateBlob(v8::SnapshotCreator::FunctionCodeHandling::kClear);
......@@ -2177,9 +2177,9 @@ TEST(SnapshotCreatorTemplates) {
c->SetAlignedPointerInInternalField(1, c1);
CHECK(context->Global()->Set(context, v8_str("a"), a).FromJust());
CHECK_EQ(0, creator.AddContext(context));
CHECK_EQ(0, creator.AddTemplate(callback));
CHECK_EQ(1, creator.AddTemplate(global_template));
CHECK_EQ(0u, creator.AddContext(context));
CHECK_EQ(0u, creator.AddTemplate(callback));
CHECK_EQ(1u, creator.AddTemplate(global_template));
}
blob = creator.CreateBlob(v8::SnapshotCreator::FunctionCodeHandling::kClear,
SerializeInternalFields);
......@@ -2248,10 +2248,10 @@ TEST(SnapshotCreatorTemplates) {
InternalFieldData* c1 = reinterpret_cast<InternalFieldData*>(
c->GetAlignedPointerFromInternalField(1));
CHECK_EQ(11, a1->data);
CHECK_EQ(20, b0->data);
CHECK_EQ(30, c0->data);
CHECK_EQ(31, c1->data);
CHECK_EQ(11u, a1->data);
CHECK_EQ(20u, b0->data);
CHECK_EQ(30u, c0->data);
CHECK_EQ(31u, c1->data);
// Accessing out of bound returns empty MaybeHandle.
CHECK(v8::ObjectTemplate::FromSnapshot(isolate, 2).IsEmpty());
......
......@@ -175,7 +175,7 @@ class ValueSerializerTest : public TestWithIsolate {
deserializer.SetSupportsLegacyWireFormat(true);
BeforeDecode(&deserializer);
ASSERT_TRUE(deserializer.ReadHeader(context).FromMaybe(false));
ASSERT_EQ(0, deserializer.GetWireFormatVersion());
ASSERT_EQ(0u, deserializer.GetWireFormatVersion());
Local<Value> result;
ASSERT_TRUE(deserializer.ReadValue(context).ToLocal(&result));
ASSERT_FALSE(result.IsEmpty());
......@@ -802,7 +802,7 @@ TEST_F(ValueSerializerTest, RoundTripArray) {
// A simple array of integers.
RoundTripTest("[1, 2, 3, 4, 5]", [this](Local<Value> value) {
ASSERT_TRUE(value->IsArray());
EXPECT_EQ(5, Array::Cast(*value)->Length());
EXPECT_EQ(5u, Array::Cast(*value)->Length());
EXPECT_TRUE(EvaluateScriptForResultBool(
"Object.getPrototypeOf(result) === Array.prototype"));
EXPECT_TRUE(
......@@ -813,14 +813,14 @@ TEST_F(ValueSerializerTest, RoundTripArray) {
"(() => { var x = new Array(1000); x[500] = 42; return x; })()",
[this](Local<Value> value) {
ASSERT_TRUE(value->IsArray());
EXPECT_EQ(1000, Array::Cast(*value)->Length());
EXPECT_EQ(1000u, Array::Cast(*value)->Length());
EXPECT_TRUE(EvaluateScriptForResultBool("result[500] === 42"));
});
// Duplicate reference.
RoundTripTest(
"(() => { var y = {}; return [y, y]; })()", [this](Local<Value> value) {
ASSERT_TRUE(value->IsArray());
ASSERT_EQ(2, Array::Cast(*value)->Length());
ASSERT_EQ(2u, Array::Cast(*value)->Length());
EXPECT_TRUE(EvaluateScriptForResultBool("result[0] === result[1]"));
});
// Duplicate reference in a sparse array.
......@@ -828,7 +828,7 @@ TEST_F(ValueSerializerTest, RoundTripArray) {
"(() => { var x = new Array(1000); x[1] = x[500] = {}; return x; })()",
[this](Local<Value> value) {
ASSERT_TRUE(value->IsArray());
ASSERT_EQ(1000, Array::Cast(*value)->Length());
ASSERT_EQ(1000u, Array::Cast(*value)->Length());
EXPECT_TRUE(
EvaluateScriptForResultBool("typeof result[1] === 'object'"));
EXPECT_TRUE(EvaluateScriptForResultBool("result[1] === result[500]"));
......@@ -838,7 +838,7 @@ TEST_F(ValueSerializerTest, RoundTripArray) {
"(() => { var y = []; y[0] = y; return y; })()",
[this](Local<Value> value) {
ASSERT_TRUE(value->IsArray());
ASSERT_EQ(1, Array::Cast(*value)->Length());
ASSERT_EQ(1u, Array::Cast(*value)->Length());
EXPECT_TRUE(EvaluateScriptForResultBool("result[0] === result"));
});
// Self reference in a sparse array.
......@@ -846,7 +846,7 @@ TEST_F(ValueSerializerTest, RoundTripArray) {
"(() => { var y = new Array(1000); y[519] = y; return y; })()",
[this](Local<Value> value) {
ASSERT_TRUE(value->IsArray());
ASSERT_EQ(1000, Array::Cast(*value)->Length());
ASSERT_EQ(1000u, Array::Cast(*value)->Length());
EXPECT_TRUE(EvaluateScriptForResultBool("result[519] === result"));
});
// Array with additional properties.
......@@ -854,7 +854,7 @@ TEST_F(ValueSerializerTest, RoundTripArray) {
"(() => { var y = [1, 2]; y.foo = 'bar'; return y; })()",
[this](Local<Value> value) {
ASSERT_TRUE(value->IsArray());
ASSERT_EQ(2, Array::Cast(*value)->Length());
ASSERT_EQ(2u, Array::Cast(*value)->Length());
EXPECT_TRUE(EvaluateScriptForResultBool("result.toString() === '1,2'"));
EXPECT_TRUE(EvaluateScriptForResultBool("result.foo === 'bar'"));
});
......@@ -863,7 +863,7 @@ TEST_F(ValueSerializerTest, RoundTripArray) {
"(() => { var y = new Array(1000); y.foo = 'bar'; return y; })()",
[this](Local<Value> value) {
ASSERT_TRUE(value->IsArray());
ASSERT_EQ(1000, Array::Cast(*value)->Length());
ASSERT_EQ(1000u, Array::Cast(*value)->Length());
EXPECT_TRUE(EvaluateScriptForResultBool(
"result.toString() === ','.repeat(999)"));
EXPECT_TRUE(EvaluateScriptForResultBool("result.foo === 'bar'"));
......@@ -871,7 +871,7 @@ TEST_F(ValueSerializerTest, RoundTripArray) {
// The distinction between holes and undefined elements must be maintained.
RoundTripTest("[,undefined]", [this](Local<Value> value) {
ASSERT_TRUE(value->IsArray());
ASSERT_EQ(2, Array::Cast(*value)->Length());
ASSERT_EQ(2u, Array::Cast(*value)->Length());
EXPECT_TRUE(
EvaluateScriptForResultBool("typeof result[0] === 'undefined'"));
EXPECT_TRUE(
......@@ -888,7 +888,7 @@ TEST_F(ValueSerializerTest, DecodeArray) {
0x49, 0x08, 0x3f, 0x01, 0x49, 0x0a, 0x24, 0x00, 0x05, 0x00},
[this](Local<Value> value) {
ASSERT_TRUE(value->IsArray());
EXPECT_EQ(5, Array::Cast(*value)->Length());
EXPECT_EQ(5u, Array::Cast(*value)->Length());
EXPECT_TRUE(EvaluateScriptForResultBool(
"Object.getPrototypeOf(result) === Array.prototype"));
EXPECT_TRUE(EvaluateScriptForResultBool(
......@@ -899,7 +899,7 @@ TEST_F(ValueSerializerTest, DecodeArray) {
0xe8, 0x07, 0x3f, 0x01, 0x49, 0x54, 0x40, 0x01, 0xe8, 0x07},
[this](Local<Value> value) {
ASSERT_TRUE(value->IsArray());
EXPECT_EQ(1000, Array::Cast(*value)->Length());
EXPECT_EQ(1000u, Array::Cast(*value)->Length());
EXPECT_TRUE(EvaluateScriptForResultBool("result[500] === 42"));
});
// Duplicate reference.
......@@ -908,7 +908,7 @@ TEST_F(ValueSerializerTest, DecodeArray) {
0x02, 0x5e, 0x01, 0x24, 0x00, 0x02},
[this](Local<Value> value) {
ASSERT_TRUE(value->IsArray());
ASSERT_EQ(2, Array::Cast(*value)->Length());
ASSERT_EQ(2u, Array::Cast(*value)->Length());
EXPECT_TRUE(EvaluateScriptForResultBool("result[0] === result[1]"));
});
// Duplicate reference in a sparse array.
......@@ -918,7 +918,7 @@ TEST_F(ValueSerializerTest, DecodeArray) {
0x07, 0x3f, 0x02, 0x5e, 0x01, 0x40, 0x02, 0xe8, 0x07, 0x00},
[this](Local<Value> value) {
ASSERT_TRUE(value->IsArray());
ASSERT_EQ(1000, Array::Cast(*value)->Length());
ASSERT_EQ(1000u, Array::Cast(*value)->Length());
EXPECT_TRUE(
EvaluateScriptForResultBool("typeof result[1] === 'object'"));
EXPECT_TRUE(EvaluateScriptForResultBool("result[1] === result[500]"));
......@@ -928,7 +928,7 @@ TEST_F(ValueSerializerTest, DecodeArray) {
0x00, 0x01, 0x00},
[this](Local<Value> value) {
ASSERT_TRUE(value->IsArray());
ASSERT_EQ(1, Array::Cast(*value)->Length());
ASSERT_EQ(1u, Array::Cast(*value)->Length());
EXPECT_TRUE(EvaluateScriptForResultBool("result[0] === result"));
});
// Self reference in a sparse array.
......@@ -937,7 +937,7 @@ TEST_F(ValueSerializerTest, DecodeArray) {
0x8e, 0x08, 0x3f, 0x01, 0x5e, 0x00, 0x40, 0x01, 0xe8, 0x07},
[this](Local<Value> value) {
ASSERT_TRUE(value->IsArray());
ASSERT_EQ(1000, Array::Cast(*value)->Length());
ASSERT_EQ(1000u, Array::Cast(*value)->Length());
EXPECT_TRUE(EvaluateScriptForResultBool("result[519] === result"));
});
// Array with additional properties.
......@@ -947,7 +947,7 @@ TEST_F(ValueSerializerTest, DecodeArray) {
0x01, 0x53, 0x03, 0x62, 0x61, 0x72, 0x24, 0x01, 0x02, 0x00},
[this](Local<Value> value) {
ASSERT_TRUE(value->IsArray());
ASSERT_EQ(2, Array::Cast(*value)->Length());
ASSERT_EQ(2u, Array::Cast(*value)->Length());
EXPECT_TRUE(EvaluateScriptForResultBool("result.toString() === '1,2'"));
EXPECT_TRUE(EvaluateScriptForResultBool("result.foo === 'bar'"));
});
......@@ -957,7 +957,7 @@ TEST_F(ValueSerializerTest, DecodeArray) {
0x62, 0x61, 0x72, 0x40, 0x01, 0xe8, 0x07, 0x00},
[this](Local<Value> value) {
ASSERT_TRUE(value->IsArray());
ASSERT_EQ(1000, Array::Cast(*value)->Length());
ASSERT_EQ(1000u, Array::Cast(*value)->Length());
EXPECT_TRUE(EvaluateScriptForResultBool(
"result.toString() === ','.repeat(999)"));
EXPECT_TRUE(EvaluateScriptForResultBool("result.foo === 'bar'"));
......@@ -969,7 +969,7 @@ TEST_F(ValueSerializerTest, DecodeArray) {
{0xff, 0x09, 0x61, 0x02, 0x49, 0x02, 0x5f, 0x40, 0x01, 0x02},
[this](Local<Value> value) {
ASSERT_TRUE(value->IsArray());
ASSERT_EQ(2, Array::Cast(*value)->Length());
ASSERT_EQ(2u, Array::Cast(*value)->Length());
EXPECT_TRUE(
EvaluateScriptForResultBool("typeof result[0] === 'undefined'"));
EXPECT_TRUE(
......@@ -999,7 +999,7 @@ TEST_F(ValueSerializerTest, RoundTripArrayWithNonEnumerableElement) {
"})()",
[this](Local<Value> value) {
ASSERT_TRUE(value->IsArray());
ASSERT_EQ(3, Array::Cast(*value)->Length());
ASSERT_EQ(3u, Array::Cast(*value)->Length());
EXPECT_TRUE(EvaluateScriptForResultBool("!result.hasOwnProperty('1')"));
});
}
......@@ -1013,7 +1013,7 @@ TEST_F(ValueSerializerTest, RoundTripArrayWithTrickyGetters) {
"})()",
[this](Local<Value> value) {
ASSERT_TRUE(value->IsArray());
ASSERT_EQ(2, Array::Cast(*value)->Length());
ASSERT_EQ(2u, Array::Cast(*value)->Length());
EXPECT_TRUE(
EvaluateScriptForResultBool("typeof result[1] === 'undefined'"));
EXPECT_TRUE(EvaluateScriptForResultBool("!result.hasOwnProperty(1)"));
......@@ -1027,7 +1027,7 @@ TEST_F(ValueSerializerTest, RoundTripArrayWithTrickyGetters) {
"})()",
[this](Local<Value> value) {
ASSERT_TRUE(value->IsArray());
ASSERT_EQ(1000, Array::Cast(*value)->Length());
ASSERT_EQ(1000u, Array::Cast(*value)->Length());
EXPECT_TRUE(
EvaluateScriptForResultBool("typeof result[1] === 'undefined'"));
EXPECT_TRUE(EvaluateScriptForResultBool("!result.hasOwnProperty(1)"));
......@@ -1041,7 +1041,7 @@ TEST_F(ValueSerializerTest, RoundTripArrayWithTrickyGetters) {
"})()",
[this](Local<Value> value) {
ASSERT_TRUE(value->IsArray());
ASSERT_EQ(4, Array::Cast(*value)->Length());
ASSERT_EQ(4u, Array::Cast(*value)->Length());
EXPECT_TRUE(EvaluateScriptForResultBool("result[0] === 1"));
EXPECT_TRUE(EvaluateScriptForResultBool("!result.hasOwnProperty(2)"));
});
......@@ -1054,7 +1054,7 @@ TEST_F(ValueSerializerTest, RoundTripArrayWithTrickyGetters) {
"})()",
[this](Local<Value> value) {
ASSERT_TRUE(value->IsArray());
ASSERT_EQ(4, Array::Cast(*value)->Length());
ASSERT_EQ(4u, Array::Cast(*value)->Length());
EXPECT_TRUE(EvaluateScriptForResultBool("result[2] === 3"));
EXPECT_TRUE(EvaluateScriptForResultBool("!result.hasOwnProperty(3)"));
});
......@@ -1067,7 +1067,7 @@ TEST_F(ValueSerializerTest, RoundTripArrayWithTrickyGetters) {
"})()",
[this](Local<Value> value) {
ASSERT_TRUE(value->IsArray());
ASSERT_EQ(1000, Array::Cast(*value)->Length());
ASSERT_EQ(1000u, Array::Cast(*value)->Length());
EXPECT_TRUE(EvaluateScriptForResultBool("result[0] === 1"));
EXPECT_TRUE(EvaluateScriptForResultBool("!result.hasOwnProperty(2)"));
});
......@@ -1079,7 +1079,7 @@ TEST_F(ValueSerializerTest, RoundTripArrayWithTrickyGetters) {
"})()",
[this](Local<Value> value) {
ASSERT_TRUE(value->IsArray());
ASSERT_EQ(1000, Array::Cast(*value)->Length());
ASSERT_EQ(1000u, Array::Cast(*value)->Length());
EXPECT_TRUE(EvaluateScriptForResultBool("result[2] === 3"));
EXPECT_TRUE(EvaluateScriptForResultBool("!result.hasOwnProperty(3)"));
});
......@@ -1094,7 +1094,7 @@ TEST_F(ValueSerializerTest, RoundTripArrayWithTrickyGetters) {
"})()",
[this](Local<Value> value) {
ASSERT_TRUE(value->IsArray());
ASSERT_EQ(2, Array::Cast(*value)->Length());
ASSERT_EQ(2u, Array::Cast(*value)->Length());
EXPECT_TRUE(EvaluateScriptForResultBool("result[1] === 3"));
});
// Same for sparse arrays.
......@@ -1108,7 +1108,7 @@ TEST_F(ValueSerializerTest, RoundTripArrayWithTrickyGetters) {
"})()",
[this](Local<Value> value) {
ASSERT_TRUE(value->IsArray());
ASSERT_EQ(1000, Array::Cast(*value)->Length());
ASSERT_EQ(1000u, Array::Cast(*value)->Length());
EXPECT_TRUE(EvaluateScriptForResultBool("result[1] === 3"));
});
// Getters on the array itself must also run.
......@@ -1120,7 +1120,7 @@ TEST_F(ValueSerializerTest, RoundTripArrayWithTrickyGetters) {
"})()",
[this](Local<Value> value) {
ASSERT_TRUE(value->IsArray());
ASSERT_EQ(3, Array::Cast(*value)->Length());
ASSERT_EQ(3u, Array::Cast(*value)->Length());
EXPECT_TRUE(EvaluateScriptForResultBool("result[1] === 4"));
});
// Same for sparse arrays.
......@@ -1133,7 +1133,7 @@ TEST_F(ValueSerializerTest, RoundTripArrayWithTrickyGetters) {
"})()",
[this](Local<Value> value) {
ASSERT_TRUE(value->IsArray());
ASSERT_EQ(1000, Array::Cast(*value)->Length());
ASSERT_EQ(1000u, Array::Cast(*value)->Length());
EXPECT_TRUE(EvaluateScriptForResultBool("result[1] === 4"));
});
// Even with a getter that deletes things, we don't read from the prototype.
......@@ -1145,7 +1145,7 @@ TEST_F(ValueSerializerTest, RoundTripArrayWithTrickyGetters) {
"})()",
[this](Local<Value> value) {
ASSERT_TRUE(value->IsArray());
ASSERT_EQ(2, Array::Cast(*value)->Length());
ASSERT_EQ(2u, Array::Cast(*value)->Length());
EXPECT_TRUE(EvaluateScriptForResultBool("!(1 in result)"));
});
// Same for sparse arrays.
......@@ -1158,7 +1158,7 @@ TEST_F(ValueSerializerTest, RoundTripArrayWithTrickyGetters) {
"})()",
[this](Local<Value> value) {
ASSERT_TRUE(value->IsArray());
ASSERT_EQ(1000, Array::Cast(*value)->Length());
ASSERT_EQ(1000u, Array::Cast(*value)->Length());
EXPECT_TRUE(EvaluateScriptForResultBool("!(1 in result)"));
});
}
......@@ -1168,7 +1168,7 @@ TEST_F(ValueSerializerTest, DecodeSparseArrayVersion0) {
DecodeTestForVersion0({0x40, 0x00, 0x00, 0x00},
[this](Local<Value> value) {
ASSERT_TRUE(value->IsArray());
ASSERT_EQ(0, Array::Cast(*value)->Length());
ASSERT_EQ(0u, Array::Cast(*value)->Length());
});
// Sparse array with a mixture of elements and properties.
DecodeTestForVersion0(
......@@ -1177,7 +1177,7 @@ TEST_F(ValueSerializerTest, DecodeSparseArrayVersion0) {
0x03, 'b', 'a', 'z', 0x49, 0x0b, 0x40, 0x04, 0x03, 0x00},
[this](Local<Value> value) {
ASSERT_TRUE(value->IsArray());
EXPECT_EQ(3, Array::Cast(*value)->Length());
EXPECT_EQ(3u, Array::Cast(*value)->Length());
EXPECT_TRUE(
EvaluateScriptForResultBool("result.toString() === 'a,,5'"));
EXPECT_TRUE(EvaluateScriptForResultBool("!(1 in result)"));
......@@ -1189,7 +1189,7 @@ TEST_F(ValueSerializerTest, DecodeSparseArrayVersion0) {
{0x55, 0x01, 0x55, 0x01, 0x54, 0x40, 0x01, 0x02, 0x40, 0x01, 0x02, 0x00},
[this](Local<Value> value) {
ASSERT_TRUE(value->IsArray());
EXPECT_EQ(2, Array::Cast(*value)->Length());
EXPECT_EQ(2u, Array::Cast(*value)->Length());
EXPECT_TRUE(EvaluateScriptForResultBool("!(0 in result)"));
EXPECT_TRUE(EvaluateScriptForResultBool("result[1] instanceof Array"));
EXPECT_TRUE(EvaluateScriptForResultBool("!(0 in result[1])"));
......@@ -1808,8 +1808,8 @@ TEST_F(ValueSerializerTest, RoundTripTypedArray) {
#define TYPED_ARRAY_ROUND_TRIP_TEST(Type, type, TYPE, ctype, size) \
RoundTripTest("new " #Type "Array(2)", [this](Local<Value> value) { \
ASSERT_TRUE(value->Is##Type##Array()); \
EXPECT_EQ(2 * size, TypedArray::Cast(*value)->ByteLength()); \
EXPECT_EQ(2, TypedArray::Cast(*value)->Length()); \
EXPECT_EQ(2u * size, TypedArray::Cast(*value)->ByteLength()); \
EXPECT_EQ(2u, TypedArray::Cast(*value)->Length()); \
EXPECT_TRUE(EvaluateScriptForResultBool( \
"Object.getPrototypeOf(result) === " #Type "Array.prototype")); \
});
......@@ -1863,8 +1863,8 @@ TEST_F(ValueSerializerTest, DecodeTypedArray) {
0x42, 0x00, 0x02},
[this](Local<Value> value) {
ASSERT_TRUE(value->IsUint8Array());
EXPECT_EQ(2, TypedArray::Cast(*value)->ByteLength());
EXPECT_EQ(2, TypedArray::Cast(*value)->Length());
EXPECT_EQ(2u, TypedArray::Cast(*value)->ByteLength());
EXPECT_EQ(2u, TypedArray::Cast(*value)->Length());
EXPECT_TRUE(EvaluateScriptForResultBool(
"Object.getPrototypeOf(result) === Uint8Array.prototype"));
});
......@@ -1872,8 +1872,8 @@ TEST_F(ValueSerializerTest, DecodeTypedArray) {
0x62, 0x00, 0x02},
[this](Local<Value> value) {
ASSERT_TRUE(value->IsInt8Array());
EXPECT_EQ(2, TypedArray::Cast(*value)->ByteLength());
EXPECT_EQ(2, TypedArray::Cast(*value)->Length());
EXPECT_EQ(2u, TypedArray::Cast(*value)->ByteLength());
EXPECT_EQ(2u, TypedArray::Cast(*value)->Length());
EXPECT_TRUE(EvaluateScriptForResultBool(
"Object.getPrototypeOf(result) === Int8Array.prototype"));
});
......@@ -1882,8 +1882,8 @@ TEST_F(ValueSerializerTest, DecodeTypedArray) {
0x00, 0x56, 0x57, 0x00, 0x04},
[this](Local<Value> value) {
ASSERT_TRUE(value->IsUint16Array());
EXPECT_EQ(4, TypedArray::Cast(*value)->ByteLength());
EXPECT_EQ(2, TypedArray::Cast(*value)->Length());
EXPECT_EQ(4u, TypedArray::Cast(*value)->ByteLength());
EXPECT_EQ(2u, TypedArray::Cast(*value)->Length());
EXPECT_TRUE(EvaluateScriptForResultBool(
"Object.getPrototypeOf(result) === Uint16Array.prototype"));
});
......@@ -1891,8 +1891,8 @@ TEST_F(ValueSerializerTest, DecodeTypedArray) {
0x00, 0x56, 0x77, 0x00, 0x04},
[this](Local<Value> value) {
ASSERT_TRUE(value->IsInt16Array());
EXPECT_EQ(4, TypedArray::Cast(*value)->ByteLength());
EXPECT_EQ(2, TypedArray::Cast(*value)->Length());
EXPECT_EQ(4u, TypedArray::Cast(*value)->ByteLength());
EXPECT_EQ(2u, TypedArray::Cast(*value)->Length());
EXPECT_TRUE(EvaluateScriptForResultBool(
"Object.getPrototypeOf(result) === Int16Array.prototype"));
});
......@@ -1900,8 +1900,8 @@ TEST_F(ValueSerializerTest, DecodeTypedArray) {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x56, 0x44, 0x00, 0x08},
[this](Local<Value> value) {
ASSERT_TRUE(value->IsUint32Array());
EXPECT_EQ(8, TypedArray::Cast(*value)->ByteLength());
EXPECT_EQ(2, TypedArray::Cast(*value)->Length());
EXPECT_EQ(8u, TypedArray::Cast(*value)->ByteLength());
EXPECT_EQ(2u, TypedArray::Cast(*value)->Length());
EXPECT_TRUE(EvaluateScriptForResultBool(
"Object.getPrototypeOf(result) === Uint32Array.prototype"));
});
......@@ -1909,8 +1909,8 @@ TEST_F(ValueSerializerTest, DecodeTypedArray) {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x56, 0x64, 0x00, 0x08},
[this](Local<Value> value) {
ASSERT_TRUE(value->IsInt32Array());
EXPECT_EQ(8, TypedArray::Cast(*value)->ByteLength());
EXPECT_EQ(2, TypedArray::Cast(*value)->Length());
EXPECT_EQ(8u, TypedArray::Cast(*value)->ByteLength());
EXPECT_EQ(2u, TypedArray::Cast(*value)->Length());
EXPECT_TRUE(EvaluateScriptForResultBool(
"Object.getPrototypeOf(result) === Int32Array.prototype"));
});
......@@ -1918,8 +1918,8 @@ TEST_F(ValueSerializerTest, DecodeTypedArray) {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x56, 0x66, 0x00, 0x08},
[this](Local<Value> value) {
ASSERT_TRUE(value->IsFloat32Array());
EXPECT_EQ(8, TypedArray::Cast(*value)->ByteLength());
EXPECT_EQ(2, TypedArray::Cast(*value)->Length());
EXPECT_EQ(8u, TypedArray::Cast(*value)->ByteLength());
EXPECT_EQ(2u, TypedArray::Cast(*value)->Length());
EXPECT_TRUE(EvaluateScriptForResultBool(
"Object.getPrototypeOf(result) === Float32Array.prototype"));
});
......@@ -1928,8 +1928,8 @@ TEST_F(ValueSerializerTest, DecodeTypedArray) {
0x00, 0x00, 0x00, 0x00, 0x56, 0x46, 0x00, 0x10},
[this](Local<Value> value) {
ASSERT_TRUE(value->IsFloat64Array());
EXPECT_EQ(16, TypedArray::Cast(*value)->ByteLength());
EXPECT_EQ(2, TypedArray::Cast(*value)->Length());
EXPECT_EQ(16u, TypedArray::Cast(*value)->ByteLength());
EXPECT_EQ(2u, TypedArray::Cast(*value)->Length());
EXPECT_TRUE(EvaluateScriptForResultBool(
"Object.getPrototypeOf(result) === Float64Array.prototype"));
});
......@@ -2004,9 +2004,9 @@ TEST_F(ValueSerializerTest, RoundTripDataView) {
RoundTripTest("new DataView(new ArrayBuffer(4), 1, 2)",
[this](Local<Value> value) {
ASSERT_TRUE(value->IsDataView());
EXPECT_EQ(1, DataView::Cast(*value)->ByteOffset());
EXPECT_EQ(2, DataView::Cast(*value)->ByteLength());
EXPECT_EQ(4, DataView::Cast(*value)->Buffer()->ByteLength());
EXPECT_EQ(1u, DataView::Cast(*value)->ByteOffset());
EXPECT_EQ(2u, DataView::Cast(*value)->ByteLength());
EXPECT_EQ(4u, DataView::Cast(*value)->Buffer()->ByteLength());
EXPECT_TRUE(EvaluateScriptForResultBool(
"Object.getPrototypeOf(result) === DataView.prototype"));
});
......@@ -2017,9 +2017,9 @@ TEST_F(ValueSerializerTest, DecodeDataView) {
0x00, 0x56, 0x3f, 0x01, 0x02},
[this](Local<Value> value) {
ASSERT_TRUE(value->IsDataView());
EXPECT_EQ(1, DataView::Cast(*value)->ByteOffset());
EXPECT_EQ(2, DataView::Cast(*value)->ByteLength());
EXPECT_EQ(4, DataView::Cast(*value)->Buffer()->ByteLength());
EXPECT_EQ(1u, DataView::Cast(*value)->ByteOffset());
EXPECT_EQ(2u, DataView::Cast(*value)->ByteLength());
EXPECT_EQ(4u, DataView::Cast(*value)->Buffer()->ByteLength());
EXPECT_TRUE(EvaluateScriptForResultBool(
"Object.getPrototypeOf(result) === DataView.prototype"));
});
......
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