summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Abseil Team <absl-team@google.com>2020-12-21 04:44:34 -0800
committerGravatar Derek Mauro <dmauro@google.com>2020-12-21 12:28:32 -0500
commit8a9ef3c5da2a9064dda0ac3c61b43b87c12c50b8 (patch)
treee6b59a8540fd6f8fa8ee86de67837696bfdccd27
parent9f8b87b71b12c1df95ffededd4560cbf5dcb95b9 (diff)
Export of internal Abseil changes
-- b95862447354428f62ae1627cf526e42ca0b7a9d by Christian Blichmann <cblichmann@google.com>: Minor cleanups: * Sorting using declarations * Changing the format of a NOLINT statement PiperOrigin-RevId: 348448885 -- 954a4375fb09267e55dfda345605b9aca54998b0 by Abseil Team <absl-team@google.com>: Enable some more Emscripten tests. Requires setting -s PRINTF_LONG_DOUBLE=1 in a recent build. PiperOrigin-RevId: 348043610 GitOrigin-RevId: b95862447354428f62ae1627cf526e42ca0b7a9d Change-Id: I517c94a5fd0feb9b99823dc8552d28fa598723fe
-rw-r--r--README.md2
-rw-r--r--absl/base/BUILD.bazel4
-rw-r--r--absl/base/internal/low_level_alloc_test.cc19
-rw-r--r--absl/random/exponential_distribution_test.cc4
-rw-r--r--absl/random/gaussian_distribution_test.cc5
-rw-r--r--absl/random/internal/iostream_state_saver_test.cc5
-rw-r--r--absl/random/uniform_real_distribution_test.cc4
-rw-r--r--absl/strings/numbers.h8
-rw-r--r--absl/strings/numbers_test.cc4
9 files changed, 29 insertions, 26 deletions
diff --git a/README.md b/README.md
index 95be3257..f1802349 100644
--- a/README.md
+++ b/README.md
@@ -80,7 +80,7 @@ Abseil contains the following C++ library components:
* [`numeric`](absl/numeric/)
<br /> The `numeric` library contains C++11-compatible 128-bit integers.
* [`status`](absl/status/)
- <br /> The `status` library contains abstractions for error handling, specifically
+ <br /> The `status` contains abstractions for error handling, specifically
`absl::Status` and `absl::StatusOr<T>`.
* [`strings`](absl/strings/)
<br /> The `strings` library contains a variety of strings routines and
diff --git a/absl/base/BUILD.bazel b/absl/base/BUILD.bazel
index 244aa8cc..5d67a507 100644
--- a/absl/base/BUILD.bazel
+++ b/absl/base/BUILD.bazel
@@ -551,7 +551,9 @@ cc_test(
srcs = ["internal/low_level_alloc_test.cc"],
copts = ABSL_TEST_COPTS,
linkopts = ABSL_DEFAULT_LINKOPTS,
- tags = ["no_test_ios_x86_64"],
+ tags = [
+ "no_test_ios_x86_64",
+ ],
deps = [
":malloc_internal",
"//absl/container:node_hash_map",
diff --git a/absl/base/internal/low_level_alloc_test.cc b/absl/base/internal/low_level_alloc_test.cc
index 2f2eaffa..31abb888 100644
--- a/absl/base/internal/low_level_alloc_test.cc
+++ b/absl/base/internal/low_level_alloc_test.cc
@@ -21,6 +21,10 @@
#include <unordered_map>
#include <utility>
+#ifdef __EMSCRIPTEN__
+#include <emscripten.h>
+#endif
+
#include "absl/container/node_hash_map.h"
namespace absl {
@@ -158,5 +162,20 @@ ABSL_NAMESPACE_END
int main(int argc, char *argv[]) {
// The actual test runs in the global constructor of `before_main`.
printf("PASS\n");
+#ifdef __EMSCRIPTEN__
+ // clang-format off
+// This is JS here. Don't try to format it.
+ MAIN_THREAD_EM_ASM({
+ if (ENVIRONMENT_IS_WEB) {
+ if (typeof TEST_FINISH === 'function') {
+ TEST_FINISH($0);
+ } else {
+ console.error('Attempted to exit with status ' + $0);
+ console.error('But TEST_FINSIHED is not a function.');
+ }
+ }
+ }, 0);
+// clang-format on
+#endif
return 0;
}
diff --git a/absl/random/exponential_distribution_test.cc b/absl/random/exponential_distribution_test.cc
index 8e9e69b6..5a8afde5 100644
--- a/absl/random/exponential_distribution_test.cc
+++ b/absl/random/exponential_distribution_test.cc
@@ -47,11 +47,7 @@ using absl::random_internal::kChiSquared;
template <typename RealType>
class ExponentialDistributionTypedTest : public ::testing::Test {};
-#if defined(__EMSCRIPTEN__)
-using RealTypes = ::testing::Types<float, double>;
-#else
using RealTypes = ::testing::Types<float, double, long double>;
-#endif // defined(__EMSCRIPTEN__)
TYPED_TEST_CASE(ExponentialDistributionTypedTest, RealTypes);
TYPED_TEST(ExponentialDistributionTypedTest, SerializeTest) {
diff --git a/absl/random/gaussian_distribution_test.cc b/absl/random/gaussian_distribution_test.cc
index 02ac578a..2aa7caf4 100644
--- a/absl/random/gaussian_distribution_test.cc
+++ b/absl/random/gaussian_distribution_test.cc
@@ -130,15 +130,12 @@ TYPED_TEST(GaussianDistributionInterfaceTest, SerializeTest) {
ss >> after;
#if defined(__powerpc64__) || defined(__PPC64__) || defined(__powerpc__) || \
- defined(__ppc__) || defined(__PPC__) || defined(__EMSCRIPTEN__)
+ defined(__ppc__) || defined(__PPC__)
if (std::is_same<TypeParam, long double>::value) {
// Roundtripping floating point values requires sufficient precision
// to reconstruct the exact value. It turns out that long double
// has some errors doing this on ppc, particularly for values
// near {1.0 +/- epsilon}.
- //
- // Emscripten is even worse, implementing long double as a 128-bit
- // type, but shipping with a strtold() that doesn't support that.
if (mean <= std::numeric_limits<double>::max() &&
mean >= std::numeric_limits<double>::lowest()) {
EXPECT_EQ(static_cast<double>(before.mean()),
diff --git a/absl/random/internal/iostream_state_saver_test.cc b/absl/random/internal/iostream_state_saver_test.cc
index 7bb8ad95..6e66266c 100644
--- a/absl/random/internal/iostream_state_saver_test.cc
+++ b/absl/random/internal/iostream_state_saver_test.cc
@@ -14,6 +14,9 @@
#include "absl/random/internal/iostream_state_saver.h"
+#include <errno.h>
+#include <stdio.h>
+
#include <sstream>
#include <string>
@@ -272,7 +275,6 @@ TEST(IOStreamStateSaver, RoundTripDoubles) {
}
}
-#if !defined(__EMSCRIPTEN__)
TEST(IOStreamStateSaver, RoundTripLongDoubles) {
// Technically, C++ only guarantees that long double is at least as large as a
// double. Practically it varies from 64-bits to 128-bits.
@@ -350,7 +352,6 @@ TEST(IOStreamStateSaver, RoundTripLongDoubles) {
}
}
}
-#endif // !defined(__EMSCRIPTEN__)
TEST(StrToDTest, DoubleMin) {
const char kV[] = "2.22507385850720138e-308";
diff --git a/absl/random/uniform_real_distribution_test.cc b/absl/random/uniform_real_distribution_test.cc
index be107cdd..8cf874d6 100644
--- a/absl/random/uniform_real_distribution_test.cc
+++ b/absl/random/uniform_real_distribution_test.cc
@@ -55,11 +55,7 @@ namespace {
template <typename RealType>
class UniformRealDistributionTest : public ::testing::Test {};
-#if defined(__EMSCRIPTEN__)
-using RealTypes = ::testing::Types<float, double>;
-#else
using RealTypes = ::testing::Types<float, double, long double>;
-#endif // defined(__EMSCRIPTEN__)
TYPED_TEST_SUITE(UniformRealDistributionTest, RealTypes);
diff --git a/absl/strings/numbers.h b/absl/strings/numbers.h
index 7966e250..ffc738fa 100644
--- a/absl/strings/numbers.h
+++ b/absl/strings/numbers.h
@@ -1,4 +1,3 @@
-//
// Copyright 2017 The Abseil Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
@@ -245,13 +244,6 @@ inline size_t FastHexToBufferZeroPad16(uint64_t val, char* out) {
} // namespace numbers_internal
-// SimpleAtoi()
-//
-// Converts a string to an integer, using `safe_strto?()` functions for actual
-// parsing, returning `true` if successful. The `safe_strto?()` functions apply
-// strict checking; the string must be a base-10 integer, optionally followed or
-// preceded by ASCII whitespace, with a value in the range of the corresponding
-// integer type.
template <typename int_type>
ABSL_MUST_USE_RESULT bool SimpleAtoi(absl::string_view str, int_type* out) {
return numbers_internal::safe_strtoi_base(str, out, 10);
diff --git a/absl/strings/numbers_test.cc b/absl/strings/numbers_test.cc
index 4ab67fb6..27616bf8 100644
--- a/absl/strings/numbers_test.cc
+++ b/absl/strings/numbers_test.cc
@@ -46,6 +46,7 @@
namespace {
+using absl::SimpleAtoi;
using absl::numbers_internal::kSixDigitsToBufferSize;
using absl::numbers_internal::safe_strto32_base;
using absl::numbers_internal::safe_strto64_base;
@@ -55,7 +56,6 @@ using absl::numbers_internal::SixDigitsToBuffer;
using absl::strings_internal::Itoa;
using absl::strings_internal::strtouint32_test_cases;
using absl::strings_internal::strtouint64_test_cases;
-using absl::SimpleAtoi;
using testing::Eq;
using testing::MatchesRegex;
@@ -380,7 +380,7 @@ TEST(NumbersTest, Atoi) {
VerifySimpleAtoiGood<uint32_t>(42, 42);
VerifySimpleAtoiGood<unsigned int>(42, 42);
VerifySimpleAtoiGood<int64_t>(-42, -42);
- VerifySimpleAtoiGood<long>(-42, -42); // NOLINT(runtime/int)
+ VerifySimpleAtoiGood<long>(-42, -42); // NOLINT: runtime-int
VerifySimpleAtoiGood<uint64_t>(42, 42);
VerifySimpleAtoiGood<size_t>(42, 42);
VerifySimpleAtoiGood<std::string::size_type>(42, 42);