v8/test/unittests/parser/ast-value-unittest.cc
Mathias Bynens 822be9b238 Normalize casing of hexadecimal digits
This patch normalizes the casing of hexadecimal digits in escape
sequences of the form `\xNN` and integer literals of the form
`0xNNNN`.

Previously, the V8 code base used an inconsistent mixture of uppercase
and lowercase.

Google’s C++ style guide uses uppercase in its examples:
https://google.github.io/styleguide/cppguide.html#Non-ASCII_Characters

Moreover, uppercase letters more clearly stand out from the lowercase
`x` (or `u`) characters at the start, as well as lowercase letters
elsewhere in strings.

BUG=v8:7109
TBR=marja@chromium.org,titzer@chromium.org,mtrofin@chromium.org,mstarzinger@chromium.org,rossberg@chromium.org,yangguo@chromium.org,mlippautz@chromium.org
NOPRESUBMIT=true

Cq-Include-Trybots: master.tryserver.blink:linux_trusty_blink_rel;master.tryserver.chromium.linux:linux_chromium_rel_ng
Change-Id: I790e21c25d96ad5d95c8229724eb45d2aa9e22d6
Reviewed-on: https://chromium-review.googlesource.com/804294
Commit-Queue: Mathias Bynens <mathias@chromium.org>
Reviewed-by: Jakob Kummerow <jkummerow@chromium.org>
Cr-Commit-Position: refs/heads/master@{#49810}
2017-12-02 01:24:40 +00:00

52 lines
1.8 KiB
C++

// Copyright 2017 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "src/ast/ast-value-factory.h"
#include "src/ast/ast.h"
#include "src/heap/heap-inl.h"
#include "src/isolate-inl.h"
#include "src/zone/zone.h"
#include "test/unittests/test-utils.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace v8 {
namespace internal {
class AstValueTest : public TestWithIsolateAndZone {
protected:
AstValueTest()
: ast_value_factory_(zone(), i_isolate()->ast_string_constants(),
i_isolate()->heap()->HashSeed()),
ast_node_factory_(&ast_value_factory_, zone()) {}
Literal* NewBigInt(const char* str) {
return ast_node_factory_.NewBigIntLiteral(AstBigInt(str),
kNoSourcePosition);
}
AstValueFactory ast_value_factory_;
AstNodeFactory ast_node_factory_;
};
TEST_F(AstValueTest, BigIntToBooleanIsTrue) {
EXPECT_FALSE(NewBigInt("0")->ToBooleanIsTrue());
EXPECT_FALSE(NewBigInt("0b0")->ToBooleanIsTrue());
EXPECT_FALSE(NewBigInt("0o0")->ToBooleanIsTrue());
EXPECT_FALSE(NewBigInt("0x0")->ToBooleanIsTrue());
EXPECT_FALSE(NewBigInt("0b000")->ToBooleanIsTrue());
EXPECT_FALSE(NewBigInt("0o00000")->ToBooleanIsTrue());
EXPECT_FALSE(NewBigInt("0x000000000")->ToBooleanIsTrue());
EXPECT_TRUE(NewBigInt("3")->ToBooleanIsTrue());
EXPECT_TRUE(NewBigInt("0b1")->ToBooleanIsTrue());
EXPECT_TRUE(NewBigInt("0o6")->ToBooleanIsTrue());
EXPECT_TRUE(NewBigInt("0xA")->ToBooleanIsTrue());
EXPECT_TRUE(NewBigInt("0b0000001")->ToBooleanIsTrue());
EXPECT_TRUE(NewBigInt("0o00005000")->ToBooleanIsTrue());
EXPECT_TRUE(NewBigInt("0x0000D00C0")->ToBooleanIsTrue());
}
} // namespace internal
} // namespace v8