Skip to content

Diverse stack unittest #7380

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Feb 10, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions include/swift/Basic/DiverseStack.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//
//
// This file defines a data structure for representing a stack of
// variably-sized objects. It is a requirement that the object type
// be trivially movable, meaning that it has a trivial move
// constructor and a trivial destructor.
//
///
/// \file
///
/// This file defines a data structure for representing a stack of
/// variably-sized objects. It is a requirement that the object type
/// be trivially movable, meaning that it has a trivial move
/// constructor and a trivial destructor.
///
//===----------------------------------------------------------------------===//

#ifndef SWIFT_BASIC_DIVERSESTACK_H
Expand Down
194 changes: 0 additions & 194 deletions unittests/Basic/ADTTests.cpp

This file was deleted.

36 changes: 19 additions & 17 deletions unittests/Basic/BlotMapVectorTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
//
//===----------------------------------------------------------------------===//

#define DEBUG_TYPE "swift-blot-map-vector-test"
#include "swift/Basic/BlotMapVector.h"
#include "swift/Basic/LLVM.h"
#include "swift/Basic/Lazy.h"
Expand All @@ -19,6 +20,7 @@
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Support/Debug.h"
#include "gtest/gtest.h"
#include <map>
#include <set>
Expand Down Expand Up @@ -93,31 +95,31 @@ class CtorTester {

CtorTester() : Value(new int(-1)) {
dump("Constructing ()");
llvm::outs() << "\n";
DEBUG(llvm::errs() << "\n");
// EXPECT_TRUE(ConstructedTesters->insert(this));
assert(!isLive());
fflush(stdout);
}

explicit CtorTester(EmptyTester) : Value(new int(-2)) {
dump("Constructing Empty");
llvm::outs() << "\n";
DEBUG(llvm::errs() << "\n");
// EXPECT_TRUE(ConstructedTesters->insert(this));
assert(!isLive());
fflush(stdout);
}

explicit CtorTester(TombstoneTester) : Value(new int(-3)) {
dump("Constructing Tombstone");
llvm::outs() << "\n";
DEBUG(llvm::errs() << "\n");
// EXPECT_TRUE(ConstructedTesters->insert(this));
assert(!isLive());
fflush(stdout);
}

explicit CtorTester(int V) : Value(new int(V)) {
dump("Constructing Normal");
llvm::outs() << "\n";
DEBUG(llvm::errs() << "\n");
EXPECT_TRUE(ConstructedTesters->insert(this));
assert(!isIgnorableTester());
assert(isLive());
Expand All @@ -126,7 +128,7 @@ class CtorTester {

explicit CtorTester(uint32_t V) : Value(new int(V)) {
dump("Constructing Normal");
llvm::outs() << "\n";
DEBUG(llvm::errs() << "\n");
EXPECT_TRUE(ConstructedTesters->insert(this));
assert(!isIgnorableTester());
assert(isLive());
Expand All @@ -136,7 +138,7 @@ class CtorTester {
CtorTester(const CtorTester &Arg) : Value(new int(*Arg.Value.get())) {
dump("CopyConstructing");
Arg.dump(" From");
llvm::outs() << "\n";
DEBUG(llvm::errs() << "\n");
if (!Arg.isIgnorableTester()) {
EXPECT_TRUE(ConstructedTesters->insert(this));
fflush(stdout);
Expand All @@ -146,7 +148,7 @@ class CtorTester {
CtorTester(CtorTester &&Arg) : Value(new int(-1)) {
dump("Operator Move Constructor");
Arg.dump(" From");
llvm::outs() << "\n";
DEBUG(llvm::errs() << "\n");
assert(Value);
assert(Arg.Value);
// If Arg is not ignorable, it will be now and we will not be.
Expand All @@ -155,13 +157,13 @@ class CtorTester {
EXPECT_EQ(1u, ConstructedTesters->erase(&Arg));
}
std::swap(Value, Arg.Value);
fflush(stdout);
DEBUG(fflush(stdout));
}

CtorTester &operator=(const CtorTester &Arg) {
dump("Operator Copy Assignment");
Arg.dump(" From");
llvm::outs() << "\n";
DEBUG(llvm::errs() << "\n");
assert(Value);
assert(Arg.Value);

Expand All @@ -178,7 +180,7 @@ class CtorTester {
CtorTester &operator=(CtorTester &&Arg) {
dump("Operator Move Assignment");
Arg.dump(" From");
llvm::outs() << "\n";
DEBUG(llvm::errs() << "\n");
assert(Value);
assert(Arg.Value);
if (!Arg.isIgnorableTester() && isIgnorableTester()) {
Expand All @@ -190,14 +192,14 @@ class CtorTester {
}

std::swap(Value, Arg.Value);
fflush(stdout);
DEBUG(fflush(stdout));
return *this;
}

~CtorTester() {
bool IsIgnorable = isIgnorableTester();
dump("Destroying");
llvm::outs() << "\n";
DEBUG(llvm::errs() << "\n");
delete Value.get();
Value = nullptr;
fflush(stdout);
Expand All @@ -224,9 +226,9 @@ class CtorTester {
Addr += llvm::utohexstr(uintptr_t(this));
std::string ValueAddr = "0x";
ValueAddr += llvm::utohexstr(uintptr_t(Value.get()));
llvm::outs() << Name << " <Tester Addr:" << Addr
<< " ValueAddr:" << ValueAddr << " Value:" << *Value.get()
<< ">";
DEBUG(llvm::errs() << Name << " <Tester Addr:" << Addr
<< " ValueAddr:" << ValueAddr << " Value:" << *Value.get()
<< ">");
}
};

Expand All @@ -236,7 +238,7 @@ void CtorTesterSet::dumpLiveTesters() const {
continue;
llvm::SmallString<64> Hex;
std::string Addr = llvm::utohexstr(uintptr_t(Tester));
llvm::outs() << "<Tester Addr:" << Addr << " Value:" << Tester->getValue()
llvm::errs() << "<Tester Addr:" << Addr << " Value:" << Tester->getValue()
<< ">\n";
}
}
Expand Down Expand Up @@ -331,7 +333,7 @@ template <typename T> class BlotMapVectorTest : public ::testing::Test {

~BlotMapVectorTest() override {
ConstructedTesters->verifyTesters();
llvm::outs() << "Destroying Fixture\n";
DEBUG(llvm::errs() << "Destroying Fixture\n");
ConstructedTesters->finalize();
}

Expand Down
Loading