Fixed broken tests
This commit is contained in:
parent
0b0344be69
commit
5e52de10bd
7 changed files with 29 additions and 98 deletions
|
|
@ -1,6 +1,4 @@
|
|||
#include "../include/heap.hpp"
|
||||
|
||||
GC::Heap *gc = GC::Heap::the();
|
||||
#include "heap.hpp"
|
||||
|
||||
struct Node {
|
||||
int id;
|
||||
|
|
@ -10,12 +8,12 @@ struct Node {
|
|||
Node *create_chain(int depth) {
|
||||
std::vector<Node*> nodes;
|
||||
if (depth > 0) {
|
||||
Node *last_node = static_cast<Node *>(gc->alloc(sizeof(Node)));
|
||||
Node *last_node = static_cast<Node *>(GC::Heap::alloc(sizeof(Node)));
|
||||
last_node->id = depth;
|
||||
last_node->child = nullptr;
|
||||
nodes.push_back(last_node);
|
||||
for (int i = 0; i < depth; i++) {
|
||||
Node *node = static_cast<Node *>(gc->alloc(sizeof(Node)));
|
||||
Node *node = static_cast<Node *>(GC::Heap::alloc(sizeof(Node)));
|
||||
node->id = depth-i;
|
||||
node->child = nodes[i-1];
|
||||
nodes.push_back(node);
|
||||
|
|
@ -30,7 +28,7 @@ Node *create_chain(int depth) {
|
|||
}
|
||||
|
||||
void create_array(size_t size) {
|
||||
int *arr = static_cast<int *>(gc->alloc(sizeof(int) * size));
|
||||
int *arr = static_cast<int *>(GC::Heap::alloc(sizeof(int) * size));
|
||||
}
|
||||
|
||||
void detach_pointer(long **ptr) {
|
||||
|
|
@ -54,19 +52,20 @@ void test_some_types() {
|
|||
auto stack_start = reinterpret_cast<uintptr_t *>(__builtin_frame_address(0));
|
||||
std::cout << "Stack start from test_some_types:\t" << stack_start << std::endl;
|
||||
|
||||
long *l = static_cast<long *>(gc->alloc(sizeof(long)));
|
||||
long *l = static_cast<long *>(GC::Heap::alloc(sizeof(long)));
|
||||
std::cout << "l points to:\t\t" << l << std::endl;
|
||||
detach_pointer(&l);
|
||||
std::cout << "l points to:\t\t" << l << std::endl;
|
||||
|
||||
// Some more dummy values of different sizes, to test stack pointer alignment
|
||||
int *i = static_cast<int *>(gc->alloc(sizeof(int)));
|
||||
char *c = static_cast<char *>(gc->alloc(sizeof(int)));
|
||||
short *s = static_cast<short *>(gc->alloc(sizeof(short)));
|
||||
int *i = static_cast<int *>(GC::Heap::alloc(sizeof(int)));
|
||||
char *c = static_cast<char *>(GC::Heap::alloc(sizeof(int)));
|
||||
short *s = static_cast<short *>(GC::Heap::alloc(sizeof(short)));
|
||||
}
|
||||
|
||||
int main() {
|
||||
gc->init();
|
||||
GC::Heap::init();
|
||||
GC::Heap *gc = GC::Heap::debug_the();
|
||||
gc->check_init();
|
||||
auto stack_start = reinterpret_cast<uintptr_t *>(__builtin_frame_address(0));
|
||||
std::cout << "Stack start from main:\t" << stack_start << std::endl;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue