Skip to content

Commit

Permalink
Removing all double-underscores.
Browse files Browse the repository at this point in the history
  • Loading branch information
bingmann committed May 21, 2015
1 parent 78c00f0 commit 94fa05c
Show file tree
Hide file tree
Showing 10 changed files with 78 additions and 64 deletions.
14 changes: 14 additions & 0 deletions scripts/analyze-source.pl
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,20 @@ sub process_cpp {
}
}

# check for double underscores
{
foreach my $ln (@data)
{
next if $ln =~ /^\s*#(if|elif|define|error)/;

if ($ln =~ m@\s__(?!(typeof__|attribute__|sync_add_and_fetch|sync_sub_and_fetch|FILE__|LINE__|FUNCTION__))@) {
print("double-underscore found in $path\n");
print $ln."\n";
system("emacsclient -n $path") if $launch_emacs;
}
}
}

# check source header
my $i = 0;
if ($data[$i] =~ m!// -.*- mode:!) { ++$i; } # skip emacs mode line
Expand Down
2 changes: 1 addition & 1 deletion testsuite/BoundTest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,6 @@ struct BoundTest : public tpunit::TestFixture
{
test_multi(320, 1000);
}
} __BoundTest;
} _BoundTest;

/******************************************************************************/
2 changes: 1 addition & 1 deletion testsuite/BulkLoadTest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,6 @@ struct BulkLoadTest : public tpunit::TestFixture
test_map_instance(32000, 10000);
test_map_instance(117649, 100000);
}
} __BulkLoadTest;
} _BulkLoadTest;

/******************************************************************************/
2 changes: 1 addition & 1 deletion testsuite/DumpRestoreTest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,6 @@ struct DumpRestoreTest : public tpunit::TestFixture
ASSERT(!bt3.restore(iss));
}
}
} __DumpRestoreTest;
} _DumpRestoreTest;

/******************************************************************************/
2 changes: 1 addition & 1 deletion testsuite/IteratorTest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -836,6 +836,6 @@ struct IteratorTest : public tpunit::TestFixture

ASSERT(map.size() == 0);
}
} __IteratorTest;
} _IteratorTest;

/******************************************************************************/
2 changes: 1 addition & 1 deletion testsuite/LargeTest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,6 @@ struct LargeTest : public tpunit::TestFixture
ASSERT(bt.empty());
ASSERT(set.empty());
}
} __LargeTest;
} _LargeTest;

/******************************************************************************/
2 changes: 1 addition & 1 deletion testsuite/RelationTest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,6 @@ struct RelationTest : public tpunit::TestFixture

ASSERT(bt1 == bt4);
}
} __RelationTest;
} _RelationTest;

/******************************************************************************/
44 changes: 22 additions & 22 deletions testsuite/SimpleTest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -238,27 +238,27 @@ struct SimpleTest : public tpunit::TestFixture
};

// test binary search on different slot sizes
struct SimpleTest<8> __SimpleTest8;
struct SimpleTest<9> __SimpleTest9;
struct SimpleTest<10> __SimpleTest10;
struct SimpleTest<11> __SimpleTest11;
struct SimpleTest<12> __SimpleTest12;
struct SimpleTest<13> __SimpleTest13;
struct SimpleTest<14> __SimpleTest14;
struct SimpleTest<15> __SimpleTest15;
struct SimpleTest<16> __SimpleTest16;
struct SimpleTest<17> __SimpleTest17;
struct SimpleTest<19> __SimpleTest19;
struct SimpleTest<20> __SimpleTest20;
struct SimpleTest<21> __SimpleTest21;
struct SimpleTest<23> __SimpleTest23;
struct SimpleTest<24> __SimpleTest24;
struct SimpleTest<32> __SimpleTest32;
struct SimpleTest<48> __SimpleTest48;
struct SimpleTest<63> __SimpleTest63;
struct SimpleTest<64> __SimpleTest64;
struct SimpleTest<65> __SimpleTest65;
struct SimpleTest<101> __SimpleTest101;
struct SimpleTest<203> __SimpleTest203;
struct SimpleTest<8> _SimpleTest8;
struct SimpleTest<9> _SimpleTest9;
struct SimpleTest<10> _SimpleTest10;
struct SimpleTest<11> _SimpleTest11;
struct SimpleTest<12> _SimpleTest12;
struct SimpleTest<13> _SimpleTest13;
struct SimpleTest<14> _SimpleTest14;
struct SimpleTest<15> _SimpleTest15;
struct SimpleTest<16> _SimpleTest16;
struct SimpleTest<17> _SimpleTest17;
struct SimpleTest<19> _SimpleTest19;
struct SimpleTest<20> _SimpleTest20;
struct SimpleTest<21> _SimpleTest21;
struct SimpleTest<23> _SimpleTest23;
struct SimpleTest<24> _SimpleTest24;
struct SimpleTest<32> _SimpleTest32;
struct SimpleTest<48> _SimpleTest48;
struct SimpleTest<63> _SimpleTest63;
struct SimpleTest<64> _SimpleTest64;
struct SimpleTest<65> _SimpleTest65;
struct SimpleTest<101> _SimpleTest101;
struct SimpleTest<203> _SimpleTest203;

/******************************************************************************/
2 changes: 1 addition & 1 deletion testsuite/StructureTest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ struct StructureTest : public tpunit::TestFixture
ASSERT(bt.size() == 320 - i - 1);
}
}
} __StructureTest;
} _StructureTest;

inline std::ostream& operator << (std::ostream& o, const struct StructureTest::testdata& t)
{
Expand Down
70 changes: 35 additions & 35 deletions testsuite/tpunit.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ extern "C" int printf(const char*, ...);
* TRACE(message); adds a trace to the test output with a user
* specified string message.
*/
#define ABORT() __assert(__FILE__, __LINE__); return;
#define FAIL() __assert(__FILE__, __LINE__);
#define ABORT() _assert(__FILE__, __LINE__); return;
#define FAIL() _assert(__FILE__, __LINE__);
#define PASS() /* do nothing */
#define TRACE(message) __trace(__FILE__, __LINE__, message);
#define TRACE(message) _trace(__FILE__, __LINE__, message);

/**
* The set of core macros for basic predicate testing of boolean
Expand Down Expand Up @@ -149,13 +149,13 @@ extern "C" int printf(const char*, ...);
* ASSERT|EXPECT_FLOAT_NEAR(lhs, rhs, abs_error); generates a failure if
* the given floating-point values exceed the absolute error.
*/
#define ASSERT_FLOAT_EQUAL(lhs, rhs) \
do { if (__fp_equal(lhs, rhs, 4)) { PASS(); } \
else { ABORT(); } \
#define ASSERT_FLOAT_EQUAL(lhs, rhs) \
do { if (_fp_equal(lhs, rhs, 4)) { PASS(); } \
else { ABORT(); } \
} while (0)
#define EXPECT_FLOAT_EQUAL(lhs, rhs) \
do { if (__fp_equal(lhs, rhs, 4)) { PASS(); } \
else { FAIL(); } \
#define EXPECT_FLOAT_EQUAL(lhs, rhs) \
do { if (_fp_equal(lhs, rhs, 4)) { PASS(); } \
else { FAIL(); } \
} while (0)
#define ASSERT_FLOAT_NEAR(lhs, rhs, abs_error) \
do { if ((((lhs) > (rhs)) ? (lhs) - (rhs) : (rhs) - (lhs)) <= (abs_error)) { PASS(); } \
Expand Down Expand Up @@ -335,7 +335,7 @@ class TestFixture
method* m24 = 0, method* m25 = 0, method* m26 = 0, method* m27 = 0,
method* m28 = 0, method* m29 = 0)
{
fixture* f = &__fixtures();
fixture* f = &_fixtures();
while (f->_next) { f = f->_next; }
f = f->_next = new fixture;

Expand Down Expand Up @@ -444,25 +444,25 @@ class TestFixture
{ return new method(this, reinterpret_cast<void (TestFixture::*)()>(_method), _name, method::TEST_METHOD); }

protected:
static int __do_run()
static int _do_run()
{
fixture* f = __fixtures()._next;
fixture* f = _fixtures()._next;
while (f)
{
printf("[--------------]\n");
__do_methods(f->_before_classes);
__do_tests(f);
__do_methods(f->_after_classes);
_do_methods(f->_before_classes);
_do_tests(f);
_do_methods(f->_after_classes);
printf("[--------------]\n\n");
f = f->_next;
}
printf("[==============]\n");
printf("[ TEST RESULTS ]\n");
printf("[==============]\n");
printf("[ PASSED ] %4i tests\n", __stats()._passes);
printf("[ FAILED ] %4i tests\n", __stats()._failures);
printf("[ PASSED ] %4i tests\n", _stats()._passes);
printf("[ FAILED ] %4i tests\n", _stats()._failures);
printf("[==============]\n");
return __stats()._failures;
return _stats()._failures;
}

/**
Expand All @@ -471,7 +471,7 @@ class TestFixture
*
* http://www.cygnus-software.com/papers/comparingfloats/comparingfloats.htm
*/
static bool __fp_equal(float lhs, float rhs, unsigned char ulps)
static bool _fp_equal(float lhs, float rhs, unsigned char ulps)
{
union
{
Expand Down Expand Up @@ -508,7 +508,7 @@ class TestFixture
*
* http://www.cygnus-software.com/papers/comparingfloats/comparingfloats.htm
*/
static bool __fp_equal(double lhs, double rhs, unsigned char ulps)
static bool _fp_equal(double lhs, double rhs, unsigned char ulps)
{
union
{
Expand Down Expand Up @@ -550,14 +550,14 @@ class TestFixture
((lhs_u.c[lsb] > rhs_u.c[lsb]) ? lhs_u.c[lsb] - rhs_u.c[lsb] : rhs_u.c[lsb] - lhs_u.c[lsb]) <= ulps;
}

static void __assert(const char* _file, int _line)
{ printf("[ ] assert #%i at %s:%i\n", ++__stats()._assertions, _file, _line); }
static void _assert(const char* _file, int _line)
{ printf("[ ] assert #%i at %s:%i\n", ++_stats()._assertions, _file, _line); }

static void __trace(const char* _file, int _line, const char* _message)
{ printf("[ ] trace #%i at %s:%i: %s\n", ++__stats()._traces, _file, _line, _message); }
static void _trace(const char* _file, int _line, const char* _message)
{ printf("[ ] trace #%i at %s:%i: %s\n", ++_stats()._traces, _file, _line, _message); }

private:
static void __do_methods(method* m)
static void _do_methods(method* m)
{
while (m)
{
Expand All @@ -566,39 +566,39 @@ class TestFixture
}
}

static void __do_tests(fixture* f)
static void _do_tests(fixture* f)
{
method* t = f->_tests;
while (t)
{
__do_methods(f->_befores);
_do_methods(f->_befores);

int _prev_assertions = __stats()._assertions;
int _prev_assertions = _stats()._assertions;
printf("[ RUN ] %s\n", t->_name);
(*t->_this.*t->_addr)();
if (_prev_assertions == __stats()._assertions)
if (_prev_assertions == _stats()._assertions)
{
printf("[ PASSED ] %s\n", t->_name);
__stats()._passes++;
_stats()._passes++;
}
else
{
printf("[ FAILED ] %s\n", t->_name);
__stats()._failures++;
_stats()._failures++;
}
t = t->_next;

__do_methods(f->_afters);
_do_methods(f->_afters);
}
}

static stats & __stats()
static stats & _stats()
{
static stats _stats;
return _stats;
}

static fixture & __fixtures()
static fixture & _fixtures()
{
static fixture _fixtures;
return _fixtures;
Expand All @@ -618,7 +618,7 @@ class Tests : private TestFixture
*
* @return The number of failing assertions. (e.g. zero if all tests pass, otherwise non-zero)
*/
static int Run() { return TestFixture::__do_run(); }
static int Run() { return TestFixture::_do_run(); }

private:
Tests() : TestFixture(0) { /* disable instance creation */ }
Expand Down

0 comments on commit 94fa05c

Please sign in to comment.