+2008-01-07 Mark Rowe <mrowe@apple.com>
+
+ Reviewed by Maciej Stachowiak.
+
+ Turn testIsInteger assertions into compile-time asserts and move them into HashTraits.h
+ where possible.
+
+ * kjs/testkjs.cpp:
+ * wtf/HashTraits.h:
+
2008-01-07 Nikolas Zimmermann <zimmermann@kde.org>
Reviewed by Mark.
using namespace KJS;
using namespace WTF;
-static void testIsInteger();
static bool fillBufferWithContentsOfFile(const UString& fileName, Vector<char>& buffer);
class StopWatch
public:
virtual UString className() const { return "global"; }
};
+COMPILE_ASSERT(!IsInteger<GlobalImp>::value, WTF_IsInteger_GlobalImp_false);
class TestFunctionImp : public JSObject {
public:
int kjsmain(int argc, char** argv)
{
- testIsInteger();
-
JSLock lock;
bool prettyPrint = false;
return success ? 0 : 3;
}
-static void testIsInteger()
-{
- // Unit tests for WTF::IsInteger. Don't have a better place for them now.
- // FIXME: move these once we create a unit test directory for WTF.
-
- ASSERT(IsInteger<bool>::value);
- ASSERT(IsInteger<char>::value);
- ASSERT(IsInteger<signed char>::value);
- ASSERT(IsInteger<unsigned char>::value);
- ASSERT(IsInteger<short>::value);
- ASSERT(IsInteger<unsigned short>::value);
- ASSERT(IsInteger<int>::value);
- ASSERT(IsInteger<unsigned int>::value);
- ASSERT(IsInteger<long>::value);
- ASSERT(IsInteger<unsigned long>::value);
- ASSERT(IsInteger<long long>::value);
- ASSERT(IsInteger<unsigned long long>::value);
-
- ASSERT(!IsInteger<char*>::value);
- ASSERT(!IsInteger<const char* >::value);
- ASSERT(!IsInteger<volatile char* >::value);
- ASSERT(!IsInteger<double>::value);
- ASSERT(!IsInteger<float>::value);
- ASSERT(!IsInteger<GlobalImp>::value);
-}
-
static bool fillBufferWithContentsOfFile(const UString& fileName, Vector<char>& buffer)
{
FILE* f = fopen(fileName.UTF8String().c_str(), "r");
#ifndef WTF_HashTraits_h
#define WTF_HashTraits_h
+#include "Assertions.h"
#include "HashFunctions.h"
#include <utility>
#include <limits>
template<> struct IsInteger<long long> { static const bool value = true; };
template<> struct IsInteger<unsigned long long> { static const bool value = true; };
+ COMPILE_ASSERT(IsInteger<bool>::value, WTF_IsInteger_bool_true);
+ COMPILE_ASSERT(IsInteger<char>::value, WTF_IsInteger_char_true);
+ COMPILE_ASSERT(IsInteger<signed char>::value, WTF_IsInteger_signed_char_true);
+ COMPILE_ASSERT(IsInteger<unsigned char>::value, WTF_IsInteger_unsigned_char_true);
+ COMPILE_ASSERT(IsInteger<short>::value, WTF_IsInteger_short_true);
+ COMPILE_ASSERT(IsInteger<unsigned short>::value, WTF_IsInteger_unsigned_short_true);
+ COMPILE_ASSERT(IsInteger<int>::value, WTF_IsInteger_int_true);
+ COMPILE_ASSERT(IsInteger<unsigned int>::value, WTF_IsInteger_unsigned_int_true);
+ COMPILE_ASSERT(IsInteger<long>::value, WTF_IsInteger_long_true);
+ COMPILE_ASSERT(IsInteger<unsigned long>::value, WTF_IsInteger_unsigned_long_true);
+ COMPILE_ASSERT(IsInteger<long long>::value, WTF_IsInteger_long_long_true);
+ COMPILE_ASSERT(IsInteger<unsigned long long>::value, WTF_IsInteger_unsigned_long_long_true);
+
+ COMPILE_ASSERT(!IsInteger<char*>::value, WTF_IsInteger_char_pointer_false);
+ COMPILE_ASSERT(!IsInteger<const char* >::value, WTF_IsInteger_const_char_pointer_false);
+ COMPILE_ASSERT(!IsInteger<volatile char* >::value, WTF_IsInteger_volatile_char_pointer__false);
+ COMPILE_ASSERT(!IsInteger<double>::value, WTF_IsInteger_double_false);
+ COMPILE_ASSERT(!IsInteger<float>::value, WTF_IsInteger_float_false);
+
template<typename T> struct HashTraits;
template<bool isInteger, typename T> struct GenericHashTraitsBase;