Skip to content

Commit

Permalink
Fix a bunch of test issues on 64 bit platforms
Browse files Browse the repository at this point in the history
  • Loading branch information
dbussink committed Oct 21, 2008
1 parent febffe3 commit d6b2ac1
Show file tree
Hide file tree
Showing 10 changed files with 21 additions and 27 deletions.
6 changes: 3 additions & 3 deletions rakelib/vm.rake
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ dep_file = "vm/.depends.mf"
vm_objs = %w[ vm/drivers/cli.o ]
vm_srcs = %w[ vm/drivers/cli.cpp ]
EX_INC = %w[ libtommath onig libffi/include
libbstring libmquark libmpa libcchash
libbstring libcchash libmquark libmpa
libltdl libev llvm/include
].map { |f| "vm/external_libs/#{f}" }

Expand Down Expand Up @@ -103,11 +103,11 @@ field_extract_headers = %w[
BC = "vm/instructions.bc"
LLVM_A = "vm/external_libs/llvm/#{LLVM_STYLE}/lib/libLLVMSystem.a"
EXTERNALS = %W[ #{LLVM_A}
vm/external_libs/libmquark/libmquark.a
vm/external_libs/libcchash/libcchash.a
vm/external_libs/libtommath/libtommath.a
vm/external_libs/libbstring/libbstring.a
vm/external_libs/libmpa/libptr_array.a
vm/external_libs/libcchash/libcchash.a
vm/external_libs/libmquark/libmquark.a
vm/external_libs/onig/.libs/libonig.a
vm/external_libs/libffi/.libs/libffi.a
vm/external_libs/libltdl/.libs/libltdl.a
Expand Down
2 changes: 1 addition & 1 deletion vm/builtin/fixnum.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ namespace rubinius {
}
}

return Fixnum::from(to_native() * other->to_native());
return Fixnum::from(a * b);
}

Integer* Fixnum::mul(STATE, Bignum* other) {
Expand Down
2 changes: 1 addition & 1 deletion vm/builtin/memorypointer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ namespace rubinius {
}

Integer* MemoryPointer::get_address(STATE) {
return Integer::from(state, (size_t)pointer);
return Integer::from(state, (uintptr_t)pointer);
}

Integer* MemoryPointer::set_address(STATE, Integer* ptr) {
Expand Down
5 changes: 1 addition & 4 deletions vm/test/test_bignum.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,10 +182,7 @@ class TestBignum : public CxxTest::TestSuite {
}

void check_float(Float* f, Float* g) {
TS_ASSERT_RELATION(std::greater<double>, f->val + TOLERANCE, g->val);
TS_ASSERT_RELATION(std::greater<double>, f->val, g->val - TOLERANCE);
TS_ASSERT_RELATION(std::greater<double>, g->val + TOLERANCE, f->val);
TS_ASSERT_RELATION(std::greater<double>, g->val, f->val - TOLERANCE);
TS_ASSERT_DELTA(f->val, g->val, TOLERANCE);
}

void test_add() {
Expand Down
4 changes: 2 additions & 2 deletions vm/test/test_bytearray.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class TestByteArray : public CxxTest::TestSuite {

void test_size() {
ByteArray* b = ByteArray::create(state, 0);
TS_ASSERT_EQUALS(b->size(state), Fixnum::from(4));
TS_ASSERT_EQUALS(b->size(state), Fixnum::from(__WORDSIZE / 8));
}

void test_to_chars() {
Expand Down Expand Up @@ -204,7 +204,7 @@ class TestByteArray : public CxxTest::TestSuite {
TS_ASSERT_SAME_DATA(b->bytes, "xyZzyx", 7);

ByteArray* c = ByteArray::create(state, 0);
TS_ASSERT_EQUALS(c->size(state)->to_native(), 4);
TS_ASSERT_EQUALS(c->size(state)->to_native(), __WORDSIZE / 8);
a->dup_into(state, c);
TS_ASSERT_SAME_DATA(c->bytes, "xyZz", 4);

Expand Down
5 changes: 1 addition & 4 deletions vm/test/test_float.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,7 @@ class TestFloat : public CxxTest::TestSuite {
}

void check_float(Float* f, Float* g) {
TS_ASSERT_RELATION(std::greater<double>, f->val + TOLERANCE, g->val);
TS_ASSERT_RELATION(std::greater<double>, f->val, g->val - TOLERANCE);
TS_ASSERT_RELATION(std::greater<double>, g->val + TOLERANCE, f->val);
TS_ASSERT_RELATION(std::greater<double>, g->val, f->val - TOLERANCE);
TS_ASSERT_DELTA(f->val, g->val, TOLERANCE);
}

void test_create() {
Expand Down
8 changes: 4 additions & 4 deletions vm/test/test_integer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ class TestInteger : public CxxTest::TestSuite {
obj = Integer::from(state, (long long)-13);
TS_ASSERT_EQUALS(obj->to_native(), (native_int)-13);

obj = Integer::from(state, 214748364712331LL);
TS_ASSERT_EQUALS(as<Bignum>(obj)->to_long_long(), 214748364712331LL);
obj = Integer::from(state, 9223372036854775807LL);
TS_ASSERT_EQUALS(as<Bignum>(obj)->to_long_long(), 9223372036854775807LL);
}

void test_from_unsigned_long_long() {
Expand All @@ -90,7 +90,7 @@ class TestInteger : public CxxTest::TestSuite {
obj = Integer::from(state, (unsigned long long)-13);
TS_ASSERT_EQUALS(obj->to_native(), (native_int)-13);

obj = Integer::from(state, 214748364712331ULL);
TS_ASSERT_EQUALS(as<Bignum>(obj)->to_ulong_long(), 214748364712331ULL);
obj = Integer::from(state, 9223372036854775808ULL);
TS_ASSERT_EQUALS(as<Bignum>(obj)->to_ulong_long(), 9223372036854775808ULL);
}
};
4 changes: 2 additions & 2 deletions vm/test/test_memorypointer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class TestMemoryPointer : public CxxTest::TestSuite {
}

void test_create() {
int thing = 3.0;
int thing = 3;
MemoryPointer* ptr = MemoryPointer::create(state, (void*)&thing);
TS_ASSERT_EQUALS(ptr->pointer, &thing);
}
Expand Down Expand Up @@ -121,7 +121,7 @@ class TestMemoryPointer : public CxxTest::TestSuite {
}

void test_read_pointer() {
int one = 1;
uintptr_t one = 1;
void *addr = &one;
MemoryPointer* ptr = MemoryPointer::create(state, addr);
MemoryPointer* p = ptr->read_pointer(state);
Expand Down
8 changes: 4 additions & 4 deletions vm/test/test_nativefunction.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -367,14 +367,14 @@ class TestNativeFunction : public CxxTest::TestSuite {
TS_ASSERT_EQUALS(as<Integer>(out)->to_native(), (native_int)13);

input = Array::create(state, 1);
input->set(state, 0, Integer::from(state, 214748364741341LL));
input->set(state, 0, Integer::from(state, 9223372036854775807LL));

msg = new Message(state, input);

out = func->call(state, msg);

TS_ASSERT(kind_of<Bignum>(out));
TS_ASSERT_EQUALS(as<Bignum>(out)->to_long_long(), 214748364741341LL);
TS_ASSERT_EQUALS(as<Bignum>(out)->to_long_long(), 9223372036854775807LL);
}

void test_bind_with_unsigned_long_long() {
Expand All @@ -401,14 +401,14 @@ class TestNativeFunction : public CxxTest::TestSuite {
TS_ASSERT_EQUALS(as<Integer>(out)->to_native(), (native_int)13);

input = Array::create(state, 1);
input->set(state, 0, Integer::from(state, 214748364741341ULL));
input->set(state, 0, Integer::from(state, 9223372036854775808ULL));

msg = new Message(state, input);

out = func->call(state, msg);

TS_ASSERT(kind_of<Bignum>(out));
TS_ASSERT_EQUALS(as<Bignum>(out)->to_ulong_long(), 214748364741341ULL);
TS_ASSERT_EQUALS(as<Bignum>(out)->to_ulong_long(), 9223372036854775808ULL);
}

void test_bind_with_void() {
Expand Down
4 changes: 2 additions & 2 deletions vm/test/test_string.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -231,12 +231,12 @@ class TestString : public CxxTest::TestSuite {
TS_ASSERT(kind_of<Fixnum>(val));
TS_ASSERT_EQUALS(as<Fixnum>(val)->to_native(), 46234326);

str = String::create(state, "2137612900674276");
str = String::create(state, "9223372036854775807");
val = str->to_i(state);
TS_ASSERT(kind_of<Bignum>(val));
Bignum *big;

big = Bignum::from(state, 46234326);
big = Bignum::from(state, 9223372036854775807LL);
big = as<Bignum>(big->mul(state, big));

TS_ASSERT(as<Bignum>(val)->equal(state, big));
Expand Down

0 comments on commit d6b2ac1

Please sign in to comment.