diff options
author | Andreas Rumpf <rumpf_a@web.de> | 2008-08-23 11:16:44 +0200 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2008-08-23 11:16:44 +0200 |
commit | 07d5a8085bbcc21a1d9d06a2976ecc00e9c8d55b (patch) | |
tree | b07a53afeb56f4bba917c1a3a843f48dd25b62be /tests | |
parent | 916c25f9a70b68eb7a5e2c45d7cc2e10c6e3a525 (diff) | |
download | Nim-07d5a8085bbcc21a1d9d06a2976ecc00e9c8d55b.tar.gz |
too many changes to list
Diffstat (limited to 'tests')
72 files changed, 95 insertions, 2137 deletions
diff --git a/tests/bench/GCBench.c b/tests/bench/GCBench.c deleted file mode 100644 index c9e77d191..000000000 --- a/tests/bench/GCBench.c +++ /dev/null @@ -1,296 +0,0 @@ -// This is adapted from a benchmark written by John Ellis and Pete Kovac -// of Post Communications. -// It was modified by Hans Boehm of Silicon Graphics. -// Translated to C++ 30 May 1997 by William D Clinger of Northeastern Univ. -// Translated to C 15 March 2000 by Hans Boehm, now at HP Labs. -// -// This is no substitute for real applications. No actual application -// is likely to behave in exactly this way. However, this benchmark was -// designed to be more representative of real applications than other -// Java GC benchmarks of which we are aware. -// It attempts to model those properties of allocation requests that -// are important to current GC techniques. -// It is designed to be used either to obtain a single overall performance -// number, or to give a more detailed estimate of how collector -// performance varies with object lifetimes. It prints the time -// required to allocate and collect balanced binary trees of various -// sizes. Smaller trees result in shorter object lifetimes. Each cycle -// allocates roughly the same amount of memory. -// Two data structures are kept around during the entire process, so -// that the measured performance is representative of applications -// that maintain some live in-memory data. One of these is a tree -// containing many pointers. The other is a large array containing -// double precision floating point numbers. Both should be of comparable -// size. -// -// The results are only really meaningful together with a specification -// of how much memory was used. It is possible to trade memory for -// better time performance. This benchmark should be run in a 32 MB -// heap, though we don't currently know how to enforce that uniformly. -// -// Unlike the original Ellis and Kovac benchmark, we do not attempt -// measure pause times. This facility should eventually be added back -// in. There are several reasons for omitting it for now. The original -// implementation depended on assumptions about the thread scheduler -// that don't hold uniformly. The results really measure both the -// scheduler and GC. Pause time measurements tend to not fit well with -// current benchmark suites. As far as we know, none of the current -// commercial Java implementations seriously attempt to minimize GC pause -// times. - -#include <stdio.h> -#include <stdlib.h> -#include <sys/time.h> - -#ifdef GC -# include "gc.h" -#endif - -#ifdef PROFIL - extern void init_profiling(); - extern dump_profile(); -#endif - -// These macros were a quick hack for the Macintosh. -// -// #define currentTime() clock() -// #define elapsedTime(x) ((1000*(x))/CLOCKS_PER_SEC) - -#define currentTime() stats_rtclock() -#define elapsedTime(x) (x) - -/* Get the current time in milliseconds */ - -unsigned -stats_rtclock( void ) -{ - struct timeval t; - struct timezone tz; - - if (gettimeofday( &t, &tz ) == -1) - return 0; - return (t.tv_sec * 1000 + t.tv_usec / 1000); -} - -static const int kStretchTreeDepth = 18; // about 16Mb -static const int kLongLivedTreeDepth = 16; // about 4Mb -static const int kArraySize = 500000; // about 4Mb -static const int kMinTreeDepth = 4; -static const int kMaxTreeDepth = 16; - -typedef struct Node0_struct { - struct Node0_struct * left; - struct Node0_struct * right; - int i, j; -} Node0; - -#ifdef HOLES -# define HOLE() GC_NEW(Node0); -#else -# define HOLE() -#endif - -typedef Node0 *Node; - -void init_Node(Node me, Node l, Node r) { - me -> left = l; - me -> right = r; -} - -#ifndef GC - void destroy_Node(Node me) { - if (me -> left) { - destroy_Node(me -> left); - } - if (me -> right) { - destroy_Node(me -> right); - } - free(me); - } -#endif - -// Nodes used by a tree of a given size -static int TreeSize(int i) { - return ((1 << (i + 1)) - 1); -} - -// Number of iterations to use for a given tree depth -static int NumIters(int i) { - return 2 * TreeSize(kStretchTreeDepth) / TreeSize(i); -} - -// Build tree top down, assigning to older objects. -static void Populate(int iDepth, Node thisNode) { - if (iDepth<=0) { - return; - } else { - iDepth--; -# ifdef GC - thisNode->left = GC_NEW(Node0); HOLE(); - thisNode->right = GC_NEW(Node0); HOLE(); -# else - thisNode->left = calloc(1, sizeof(Node0)); - thisNode->right = calloc(1, sizeof(Node0)); -# endif - Populate (iDepth, thisNode->left); - Populate (iDepth, thisNode->right); - } -} - -// Build tree bottom-up -static Node MakeTree(int iDepth) { - Node result; - if (iDepth<=0) { -# ifndef GC - result = calloc(1, sizeof(Node0)); -# else - result = GC_NEW(Node0); HOLE(); -# endif - /* result is implicitly initialized in both cases. */ - return result; - } else { - Node left = MakeTree(iDepth-1); - Node right = MakeTree(iDepth-1); -# ifndef GC - result = malloc(sizeof(Node0)); -# else - result = GC_NEW(Node0); HOLE(); -# endif - init_Node(result, left, right); - return result; - } -} - -static void PrintDiagnostics() { -#if 0 - long lFreeMemory = Runtime.getRuntime().freeMemory(); - long lTotalMemory = Runtime.getRuntime().totalMemory(); - - System.out.print(" Total memory available=" - + lTotalMemory + " bytes"); - System.out.println(" Free memory=" + lFreeMemory + " bytes"); -#endif -} - -static void TimeConstruction(int depth) { - long tStart, tFinish; - int iNumIters = NumIters(depth); - Node tempTree; - int i; - - printf("Creating %d trees of depth %d\n", iNumIters, depth); - - tStart = currentTime(); - for (i = 0; i < iNumIters; ++i) { -# ifndef GC - tempTree = calloc(1, sizeof(Node0)); -# else - tempTree = GC_NEW(Node0); -# endif - Populate(depth, tempTree); -# ifndef GC - destroy_Node(tempTree); -# endif - tempTree = 0; - } - tFinish = currentTime(); - printf("\tTop down construction took %d msec\n", - elapsedTime(tFinish - tStart)); - - tStart = currentTime(); - for (i = 0; i < iNumIters; ++i) { - tempTree = MakeTree(depth); -# ifndef GC - destroy_Node(tempTree); -# endif - tempTree = 0; - } - tFinish = currentTime(); - printf("\tBottom up construction took %d msec\n", - elapsedTime(tFinish - tStart)); - -} - -int main() { - Node root; - Node longLivedTree; - Node tempTree; - long tStart, tFinish; - long tElapsed; - int i, d; - double *array; - -#ifdef GC - // GC_full_freq = 30; - // GC_free_space_divisor = 16; - // GC_enable_incremental(); -#endif - printf("Garbage Collector Test\n"); - printf(" Live storage will peak at %d bytes.\n\n", - 2 * sizeof(Node0) * TreeSize(kLongLivedTreeDepth) + - sizeof(double) * kArraySize); - printf(" Stretching memory with a binary tree of depth %d\n", - kStretchTreeDepth); - PrintDiagnostics(); -# ifdef PROFIL - init_profiling(); -# endif - - tStart = currentTime(); - - // Stretch the memory space quickly - tempTree = MakeTree(kStretchTreeDepth); -# ifndef GC - destroy_Node(tempTree); -# endif - tempTree = 0; - - // Create a long lived object - printf(" Creating a long-lived binary tree of depth %d\n", - kLongLivedTreeDepth); -# ifndef GC - longLivedTree = calloc(1, sizeof(Node0)); -# else - longLivedTree = GC_NEW(Node0); -# endif - Populate(kLongLivedTreeDepth, longLivedTree); - - // Create long-lived array, filling half of it - printf(" Creating a long-lived array of %d doubles\n", kArraySize); -# ifndef GC - array = malloc(kArraySize * sizeof(double)); -# else -# ifndef NO_PTRFREE - array = GC_MALLOC_ATOMIC(sizeof(double) * kArraySize); -# else - array = GC_MALLOC(sizeof(double) * kArraySize); -# endif -# endif - for (i = 0; i < kArraySize/2; ++i) { - array[i] = 1.0/i; - } - PrintDiagnostics(); - - for (d = kMinTreeDepth; d <= kMaxTreeDepth; d += 2) { - TimeConstruction(d); - } - - if (longLivedTree == 0 || array[1000] != 1.0/1000) - fprintf(stderr, "Failed\n"); - // fake reference to LongLivedTree - // and array - // to keep them from being optimized away - - tFinish = currentTime(); - tElapsed = elapsedTime(tFinish-tStart); - PrintDiagnostics(); - printf("Completed in %d msec\n", tElapsed); -# ifdef GC - printf("Completed %d collections\n", GC_gc_no); - printf("Heap size is %d\n", GC_get_heap_size()); -# endif -# ifdef PROFIL - dump_profile(); -# endif -} - diff --git a/tests/bench/GCBench.cpp b/tests/bench/GCBench.cpp deleted file mode 100644 index bd5e286a7..000000000 --- a/tests/bench/GCBench.cpp +++ /dev/null @@ -1,266 +0,0 @@ -// This is adapted from a benchmark written by John Ellis and Pete Kovac -// of Post Communications. -// It was modified by Hans Boehm of Silicon Graphics. -// Translated to C++ 30 May 1997 by William D Clinger of Northeastern Univ. -// -// This is no substitute for real applications. No actual application -// is likely to behave in exactly this way. However, this benchmark was -// designed to be more representative of real applications than other -// Java GC benchmarks of which we are aware. -// It attempts to model those properties of allocation requests that -// are important to current GC techniques. -// It is designed to be used either to obtain a single overall performance -// number, or to give a more detailed estimate of how collector -// performance varies with object lifetimes. It prints the time -// required to allocate and collect balanced binary trees of various -// sizes. Smaller trees result in shorter object lifetimes. Each cycle -// allocates roughly the same amount of memory. -// Two data structures are kept around during the entire process, so -// that the measured performance is representative of applications -// that maintain some live in-memory data. One of these is a tree -// containing many pointers. The other is a large array containing -// double precision floating point numbers. Both should be of comparable -// size. -// -// The results are only really meaningful together with a specification -// of how much memory was used. It is possible to trade memory for -// better time performance. This benchmark should be run in a 32 MB -// heap, though we don't currently know how to enforce that uniformly. -// -// Unlike the original Ellis and Kovac benchmark, we do not attempt -// measure pause times. This facility should eventually be added back -// in. There are several reasons for omitting it for now. The original -// implementation depended on assumptions about the thread scheduler -// that don't hold uniformly. The results really measure both the -// scheduler and GC. Pause time measurements tend to not fit well with -// current benchmark suites. As far as we know, none of the current -// commercial Java implementations seriously attempt to minimize GC pause -// times. - -#include <new.h> -#include <iostream.h> -#include <sys/time.h> - -#ifdef GC -# include "gc.h" -#endif - -// These macros were a quick hack for the Macintosh. -// -// #define currentTime() clock() -// #define elapsedTime(x) ((1000*(x))/CLOCKS_PER_SEC) - -#define currentTime() stats_rtclock() -#define elapsedTime(x) (x) - -/* Get the current time in milliseconds */ - -unsigned -stats_rtclock( void ) -{ - struct timeval t; - struct timezone tz; - - if (gettimeofday( &t, &tz ) == -1) - return 0; - return (t.tv_sec * 1000 + t.tv_usec / 1000); -} - -static const int kStretchTreeDepth = 18; // about 16Mb -static const int kLongLivedTreeDepth = 16; // about 4Mb -static const int kArraySize = 500000; // about 4Mb -static const int kMinTreeDepth = 4; -static const int kMaxTreeDepth = 16; - -typedef struct Node0 *Node; - -struct Node0 { - Node left; - Node right; - int i, j; - Node0(Node l, Node r) { left = l; right = r; } - Node0() { left = 0; right = 0; } -# ifndef GC - ~Node0() { if (left) delete left; if (right) delete right; } -# endif -}; - -struct GCBench { - - // Nodes used by a tree of a given size - static int TreeSize(int i) { - return ((1 << (i + 1)) - 1); - } - - // Number of iterations to use for a given tree depth - static int NumIters(int i) { - return 2 * TreeSize(kStretchTreeDepth) / TreeSize(i); - } - - // Build tree top down, assigning to older objects. - static void Populate(int iDepth, Node thisNode) { - if (iDepth<=0) { - return; - } else { - iDepth--; -# ifndef GC - thisNode->left = new Node0(); - thisNode->right = new Node0(); -# else - thisNode->left = new (GC_NEW(Node0)) Node0(); - thisNode->right = new (GC_NEW(Node0)) Node0(); -# endif - Populate (iDepth, thisNode->left); - Populate (iDepth, thisNode->right); - } - } - - // Build tree bottom-up - static Node MakeTree(int iDepth) { - if (iDepth<=0) { -# ifndef GC - return new Node0(); -# else - return new (GC_NEW(Node0)) Node0(); -# endif - } else { -# ifndef GC - return new Node0(MakeTree(iDepth-1), - MakeTree(iDepth-1)); -# else - return new (GC_NEW(Node0)) Node0(MakeTree(iDepth-1), - MakeTree(iDepth-1)); -# endif - } - } - - static void PrintDiagnostics() { -#if 0 - long lFreeMemory = Runtime.getRuntime().freeMemory(); - long lTotalMemory = Runtime.getRuntime().totalMemory(); - - System.out.print(" Total memory available=" - + lTotalMemory + " bytes"); - System.out.println(" Free memory=" + lFreeMemory + " bytes"); -#endif - } - - static void TimeConstruction(int depth) { - long tStart, tFinish; - int iNumIters = NumIters(depth); - Node tempTree; - - cout << "Creating " << iNumIters - << " trees of depth " << depth << endl; - - tStart = currentTime(); - for (int i = 0; i < iNumIters; ++i) { -# ifndef GC - tempTree = new Node0(); -# else - tempTree = new (GC_NEW(Node0)) Node0(); -# endif - Populate(depth, tempTree); -# ifndef GC - delete tempTree; -# endif - tempTree = 0; - } - tFinish = currentTime(); - cout << "\tTop down construction took " - << elapsedTime(tFinish - tStart) << " msec" << endl; - - tStart = currentTime(); - for (int i = 0; i < iNumIters; ++i) { - tempTree = MakeTree(depth); -# ifndef GC - delete tempTree; -# endif - tempTree = 0; - } - tFinish = currentTime(); - cout << "\tBottom up construction took " - << elapsedTime(tFinish - tStart) << " msec" << endl; - - } - - void main() { - Node root; - Node longLivedTree; - Node tempTree; - long tStart, tFinish; - long tElapsed; - -#ifdef GC -// GC_full_freq = 30; -GC_enable_incremental(); -#endif - cout << "Garbage Collector Test" << endl; - cout << " Live storage will peak at " - << 2 * sizeof(Node0) * TreeSize(kLongLivedTreeDepth) + - sizeof(double) * kArraySize - << " bytes." << endl << endl; - cout << " Stretching memory with a binary tree of depth " - << kStretchTreeDepth << endl; - PrintDiagnostics(); - - tStart = currentTime(); - - // Stretch the memory space quickly - tempTree = MakeTree(kStretchTreeDepth); -# ifndef GC - delete tempTree; -# endif - tempTree = 0; - - // Create a long lived object - cout << " Creating a long-lived binary tree of depth " - << kLongLivedTreeDepth << endl; -# ifndef GC - longLivedTree = new Node0(); -# else - longLivedTree = new (GC_NEW(Node0)) Node0(); -# endif - Populate(kLongLivedTreeDepth, longLivedTree); - - // Create long-lived array, filling half of it - cout << " Creating a long-lived array of " - << kArraySize << " doubles" << endl; -# ifndef GC - double *array = new double[kArraySize]; -# else - double *array = (double *) - GC_MALLOC_ATOMIC(sizeof(double) * kArraySize); -# endif - for (int i = 0; i < kArraySize/2; ++i) { - array[i] = 1.0/i; - } - PrintDiagnostics(); - - for (int d = kMinTreeDepth; d <= kMaxTreeDepth; d += 2) -{ - TimeConstruction(d); - } - - if (longLivedTree == 0 || array[1000] != 1.0/1000) - cout << "Failed" << endl; - // fake reference to LongLivedTree - // and array - // to keep them from being optimized away - - tFinish = currentTime(); - tElapsed = elapsedTime(tFinish-tStart); - PrintDiagnostics(); - cout << "Completed in " << tElapsed << " msec" << endl; -# ifdef GC - cout << "Completed " << GC_gc_no << " collections" <<endl; - cout << "Heap size is " << GC_get_heap_size() << endl; -# endif - } -}; - -main () { - GCBench x; - x.main(); -} - diff --git a/tests/bench/GCBench.java b/tests/bench/GCBench.java deleted file mode 100644 index ec9b93de8..000000000 --- a/tests/bench/GCBench.java +++ /dev/null @@ -1,182 +0,0 @@ -// This is adapted from a benchmark written by John Ellis and Pete Kovac -// of Post Communications. -// It was modified by Hans Boehm of Silicon Graphics. -// -// This is no substitute for real applications. No actual application -// is likely to behave in exactly this way. However, this benchmark was -// designed to be more representative of real applications than other -// Java GC benchmarks of which we are aware. -// It attempts to model those properties of allocation requests that -// are important to current GC techniques. -// It is designed to be used either to obtain a single overall performance -// number, or to give a more detailed estimate of how collector -// performance varies with object lifetimes. It prints the time -// required to allocate and collect balanced binary trees of various -// sizes. Smaller trees result in shorter object lifetimes. Each cycle -// allocates roughly the same amount of memory. -// Two data structures are kept around during the entire process, so -// that the measured performance is representative of applications -// that maintain some live in-memory data. One of these is a tree -// containing many pointers. The other is a large array containing -// double precision floating point numbers. Both should be of comparable -// size. -// -// The results are only really meaningful together with a specification -// of how much memory was used. It is possible to trade memory for -// better time performance. This benchmark should be run in a 32 MB -// heap, though we don't currently know how to enforce that uniformly. -// -// Unlike the original Ellis and Kovac benchmark, we do not attempt -// measure pause times. This facility should eventually be added back -// in. There are several reasons for omitting it for now. The original -// implementation depended on assumptions about the thread scheduler -// that don't hold uniformly. The results really measure both the -// scheduler and GC. Pause time measurements tend to not fit well with -// current benchmark suites. As far as we know, none of the current -// commercial Java implementations seriously attempt to minimize GC pause -// times. -// -// Known deficiencies: -// - No way to check on memory use -// - No cyclic data structures -// - No attempt to measure variation with object size -// - Results are sensitive to locking cost, but we dont -// check for proper locking - -class Node { - Node left, right; - int i, j; - Node(Node l, Node r) { left = l; right = r; } - Node() { } -} - -public class GCBench { - - public static final int kStretchTreeDepth = 18; // about 16Mb - public static final int kLongLivedTreeDepth = 16; // about 4Mb - public static final int kArraySize = 500000; // about 4Mb - public static final int kMinTreeDepth = 4; - public static final int kMaxTreeDepth = 16; - - // Nodes used by a tree of a given size - static int TreeSize(int i) { - return ((1 << (i + 1)) - 1); - } - - // Number of iterations to use for a given tree depth - static int NumIters(int i) { - return 2 * TreeSize(kStretchTreeDepth) / TreeSize(i); - } - - // Build tree top down, assigning to older objects. - static void Populate(int iDepth, Node thisNode) { - if (iDepth<=0) { - return; - } else { - iDepth--; - thisNode.left = new Node(); - thisNode.right = new Node(); - Populate (iDepth, thisNode.left); - Populate (iDepth, thisNode.right); - } - } - - // Build tree bottom-up - static Node MakeTree(int iDepth) { - if (iDepth<=0) { - return new Node(); - } else { - return new Node(MakeTree(iDepth-1), - MakeTree(iDepth-1)); - } - } - - static void PrintDiagnostics() { - long lFreeMemory = Runtime.getRuntime().freeMemory(); - long lTotalMemory = Runtime.getRuntime().totalMemory(); - - System.out.print(" Total memory available=" - + lTotalMemory + " bytes"); - System.out.println(" Free memory=" + lFreeMemory + " bytes"); - } - - static void TimeConstruction(int depth) { - Node root; - long tStart, tFinish; - int iNumIters = NumIters(depth); - Node tempTree; - - System.out.println("Creating " + iNumIters + - " trees of depth " + depth); - tStart = System.currentTimeMillis(); - for (int i = 0; i < iNumIters; ++i) { - tempTree = new Node(); - Populate(depth, tempTree); - tempTree = null; - } - tFinish = System.currentTimeMillis(); - System.out.println("\tTop down construction took " - + (tFinish - tStart) + "msecs"); - tStart = System.currentTimeMillis(); - for (int i = 0; i < iNumIters; ++i) { - tempTree = MakeTree(depth); - tempTree = null; - } - tFinish = System.currentTimeMillis(); - System.out.println("\tBottom up construction took " - + (tFinish - tStart) + "msecs"); - - } - - public static void main(String args[]) { - Node root; - Node longLivedTree; - Node tempTree; - long tStart, tFinish; - long tElapsed; - - - System.out.println("Garbage Collector Test"); - System.out.println( - " Stretching memory with a binary tree of depth " - + kStretchTreeDepth); - PrintDiagnostics(); - tStart = System.currentTimeMillis(); - - // Stretch the memory space quickly - tempTree = MakeTree(kStretchTreeDepth); - tempTree = null; - - // Create a long lived object - System.out.println( - " Creating a long-lived binary tree of depth " + - kLongLivedTreeDepth); - longLivedTree = new Node(); - Populate(kLongLivedTreeDepth, longLivedTree); - - // Create long-lived array, filling half of it - System.out.println( - " Creating a long-lived array of " - + kArraySize + " doubles"); - double array[] = new double[kArraySize]; - for (int i = 0; i < kArraySize/2; ++i) { - array[i] = 1.0/i; - } - PrintDiagnostics(); - - for (int d = kMinTreeDepth; d <= kMaxTreeDepth; d += 2) { - TimeConstruction(d); - } - - if (longLivedTree == null || array[1000] != 1.0/1000) - System.out.println("Failed"); - // fake reference to LongLivedTree - // and array - // to keep them from being optimized away - - tFinish = System.currentTimeMillis(); - tElapsed = tFinish-tStart; - PrintDiagnostics(); - System.out.println("Completed in " + tElapsed + "ms."); - } -} // class JavaGC diff --git a/tests/bench/GCBench_OGC.cpp b/tests/bench/GCBench_OGC.cpp deleted file mode 100644 index 2669da603..000000000 --- a/tests/bench/GCBench_OGC.cpp +++ /dev/null @@ -1,301 +0,0 @@ -// This is adapted from a benchmark written by John Ellis and Pete Kovac -// of Post Communications. -// It was modified by Hans Boehm of Silicon Graphics. -// Translated to C++ 30 May 1997 by William D Clinger of Northeastern Univ. -// -// This is no substitute for real applications. No actual application -// is likely to behave in exactly this way. However, this benchmark was -// designed to be more representative of real applications than other -// Java GC benchmarks of which we are aware. -// It attempts to model those properties of allocation requests that -// are important to current GC techniques. -// It is designed to be used either to obtain a single overall performance -// number, or to give a more detailed estimate of how collector -// performance varies with object lifetimes. It prints the time -// required to allocate and collect balanced binary trees of various -// sizes. Smaller trees result in shorter object lifetimes. Each cycle -// allocates roughly the same amount of memory. -// Two data structures are kept around during the entire process, so -// that the measured performance is representative of applications -// that maintain some live in-memory data. One of these is a tree -// containing many pointers. The other is a large array containing -// double precision floating point numbers. Both should be of comparable -// size. -// -// The results are only really meaningful together with a specification -// of how much memory was used. It is possible to trade memory for -// better time performance. This benchmark should be run in a 32 MB -// heap, though we don't currently know how to enforce that uniformly. -// -// Unlike the original Ellis and Kovac benchmark, we do not attempt -// measure pause times. This facility should eventually be added back -// in. There are several reasons for omitting it for now. The original -// implementation depended on assumptions about the thread scheduler -// that don't hold uniformly. The results really measure both the -// scheduler and GC. Pause time measurements tend to not fit well with -// current benchmark suites. As far as we know, none of the current -// commercial Java implementations seriously attempt to minimize GC pause -// times. - -#include <new.h> -#include <iostream.h> -#include <sys/time.h> - -#ifdef GC -# include "gc.h" -#endif -#ifdef OGC -# include "ogc.h" -#endif - -// These macros were a quick hack for the Macintosh. -// -// #define currentTime() clock() -// #define elapsedTime(x) ((1000*(x))/CLOCKS_PER_SEC) - -#define currentTime() stats_rtclock() -#define elapsedTime(x) (x) - -/* Get the current time in milliseconds */ - -unsigned -stats_rtclock( void ) -{ - struct timeval t; - struct timezone tz; - - if (gettimeofday( &t, &tz ) == -1) - return 0; - return (t.tv_sec * 1000 + t.tv_usec / 1000); -} - -static const int kStretchTreeDepth = 18; // about 16Mb -static const int kLongLivedTreeDepth = 16; // about 4Mb -static const int kArraySize = 500000; // about 4Mb -static const int kMinTreeDepth = 4; -static const int kMaxTreeDepth = 16; - -struct Node0 { -# ifdef OGC - gc_ptr<Node0> left; - gc_ptr<Node0> right; - Node0(gc_ptr<Node0> l, gc_ptr<Node0> r) { left = l; right = r; } -# else - Node0 * left; - Node0 * right; - Node0(Node0 *l, Node0 *r) { left = l; right = r; } -# endif - int i, j; - Node0() { left = 0; right = 0; } -# if !defined(GC) && !defined(OGC) - ~Node0() { if (left) delete left; if (right) delete right; } -# endif -}; - -#ifdef OGC -typedef gc_ptr<Node0> Node; -#else -typedef struct Node0 *Node; -#endif - -struct GCBench { - - // Nodes used by a tree of a given size - static int TreeSize(int i) { - return ((1 << (i + 1)) - 1); - } - - // Number of iterations to use for a given tree depth - static int NumIters(int i) { - return 2 * TreeSize(kStretchTreeDepth) / TreeSize(i); - } - - // Build tree top down, assigning to older objects. - static void Populate(int iDepth, Node thisNode) { - if (iDepth<=0) { - return; - } else { - iDepth--; -# if defined(GC) - thisNode->left = new (GC_NEW(Node0)) Node0(); - thisNode->right = new (GC_NEW(Node0)) Node0(); -# elif defined(OGC) - thisNode->left = gc_new Node0(); - thisNode->right = gc_new Node0(); -# else - thisNode->left = new Node0(); - thisNode->right = new Node0(); -# endif - Populate (iDepth, thisNode->left); - Populate (iDepth, thisNode->right); - } - } - - // Build tree bottom-up - static Node MakeTree(int iDepth) { - if (iDepth<=0) { -# if defined(GC) - return new (GC_NEW(Node0)) Node0(); -# elif defined(OGC) - return gc_new Node0(); -# else - return new Node0(); -# endif - } else { -# if defined(GC) - return new (GC_NEW(Node0)) Node0(MakeTree(iDepth-1), - MakeTree(iDepth-1)); -# elif defined(OGC) -# ifdef BROKEN_SMART_PTRS - Node left = MakeTree(iDepth-1); - Node right = MakeTree(iDepth-1); - return gc_new Node0(left, right); -# else - return gc_new Node0(MakeTree(iDepth-1), - MakeTree(iDepth-1)); -# endif -# else - return new Node0(MakeTree(iDepth-1), - MakeTree(iDepth-1)); -# endif - } - } - - static void PrintDiagnostics() { -#if 0 - long lFreeMemory = Runtime.getRuntime().freeMemory(); - long lTotalMemory = Runtime.getRuntime().totalMemory(); - - System.out.print(" Total memory available=" - + lTotalMemory + " bytes"); - System.out.println(" Free memory=" + lFreeMemory + " bytes"); -#endif - } - - static void TimeConstruction(int depth) { - long tStart, tFinish; - int iNumIters = NumIters(depth); - Node tempTree; - - cout << "Creating " << iNumIters - << " trees of depth " << depth << endl; - - tStart = currentTime(); - for (int i = 0; i < iNumIters; ++i) { -# if defined(GC) - tempTree = new (GC_NEW(Node0)) Node0(); -# elif defined(OGC) - tempTree = gc_new Node0(); -# else - tempTree = new Node0(); -# endif - Populate(depth, tempTree); -# if !defined(GC) && !defined(OGC) - delete tempTree; -# endif - tempTree = 0; - } - tFinish = currentTime(); - cout << "\tTop down construction took " - << elapsedTime(tFinish - tStart) << " msec" << endl; - - tStart = currentTime(); - for (int i = 0; i < iNumIters; ++i) { - tempTree = MakeTree(depth); -# if !defined(GC) && !defined(OGC) - delete tempTree; -# endif - tempTree = 0; - } - tFinish = currentTime(); - cout << "\tBottom up construction took " - << elapsedTime(tFinish - tStart) << " msec" << endl; - - } - - void main() { - Node root; - Node longLivedTree; - Node tempTree; - long tStart, tFinish; - long tElapsed; - -#ifdef GC -// GC_full_freq = 30; -GC_enable_incremental(); -#endif - -# ifdef OGC - GC::SetPolicy(100); -# endif - cout << "Garbage Collector Test" << endl; - cout << " Live storage will peak at " - << 2 * sizeof(Node0) * TreeSize(kLongLivedTreeDepth) + - sizeof(double) * kArraySize - << " bytes." << endl << endl; - cout << " Stretching memory with a binary tree of depth " - << kStretchTreeDepth << endl; - PrintDiagnostics(); - - tStart = currentTime(); - - // Stretch the memory space quickly - tempTree = MakeTree(kStretchTreeDepth); -# if !defined(GC) && !defined(OGC) - delete tempTree; -# endif - tempTree = 0; - - // Create a long lived object - cout << " Creating a long-lived binary tree of depth " - << kLongLivedTreeDepth << endl; -# if defined(GC) - longLivedTree = new (GC_NEW(Node0)) Node0(); -# elif defined(OGC) - longLivedTree = gc_new Node0(); -# else - longLivedTree = new Node0(); -# endif - Populate(kLongLivedTreeDepth, longLivedTree); - - // Create long-lived array, filling half of it - cout << " Creating a long-lived array of " - << kArraySize << " doubles" << endl; -# if defined(GC) - double *array = (double *) - GC_MALLOC(sizeof(double) * kArraySize); -# else - double *array = new double[kArraySize]; -# endif - for (int i = 0; i < kArraySize/2; ++i) { - array[i] = 1.0/i; - } - PrintDiagnostics(); - - for (int d = kMinTreeDepth; d <= kMaxTreeDepth; d += 2) -{ - TimeConstruction(d); - } - - if (longLivedTree == 0 || array[1000] != 1.0/1000) - cout << "Failed" << endl; - // fake reference to LongLivedTree - // and array - // to keep them from being optimized away - - tFinish = currentTime(); - tElapsed = elapsedTime(tFinish-tStart); - PrintDiagnostics(); - cout << "Completed in " << tElapsed << " msec" << endl; -# ifdef GC - cout << "Completed " << GC_gc_no << " collections" <<endl; - cout << "Heap size is " << GC_get_heap_size() << endl; -# endif - } -}; - -main () { - GCBench x; - x.main(); -} - diff --git a/tests/bench/gcbench.nim b/tests/bench/gcbench.nim deleted file mode 100644 index 9f69b0cdc..000000000 --- a/tests/bench/gcbench.nim +++ /dev/null @@ -1,172 +0,0 @@ -# This is adapted from a benchmark written by John Ellis and Pete Kovac -# of Post Communications. -# It was modified by Hans Boehm of Silicon Graphics. -# -# This is no substitute for real applications. No actual application -# is likely to behave in exactly this way. However, this benchmark was -# designed to be more representative of real applications than other -# Java GC benchmarks of which we are aware. -# It attempts to model those properties of allocation requests that -# are important to current GC techniques. -# It is designed to be used either to obtain a single overall performance -# number, or to give a more detailed estimate of how collector -# performance varies with object lifetimes. It prints the time -# required to allocate and collect balanced binary trees of various -# sizes. Smaller trees result in shorter object lifetimes. Each cycle -# allocates roughly the same amount of memory. -# Two data structures are kept around during the entire process, so -# that the measured performance is representative of applications -# that maintain some live in-memory data. One of these is a tree -# containing many pointers. The other is a large array containing -# double precision floating point numbers. Both should be of comparable -# size. -# -# The results are only really meaningful together with a specification -# of how much memory was used. It is possible to trade memory for -# better time performance. This benchmark should be run in a 32 MB -# heap, though we don't currently know how to enforce that uniformly. -# -# Unlike the original Ellis and Kovac benchmark, we do not attempt -# measure pause times. This facility should eventually be added back -# in. There are several reasons for omitting it for now. The original -# implementation depended on assumptions about the thread scheduler -# that don't hold uniformly. The results really measure both the -# scheduler and GC. Pause time measurements tend to not fit well with -# current benchmark suites. As far as we know, none of the current -# commercial Java implementations seriously attempt to minimize GC pause -# times. -# -# Known deficiencies: -# - No way to check on memory use -# - No cyclic data structures -# - No attempt to measure variation with object size -# - Results are sensitive to locking cost, but we dont -# check for proper locking -# - -import - io, strutils, times - -type - PNode = ref TNode - TNode = record - left, right: PNode - i, j: int - -proc newNode(l, r: PNode): PNode = - new(result) - result.left = l - result.right = r - -const - kStretchTreeDepth = 18 # about 16Mb - kLongLivedTreeDepth = 16 # about 4Mb - kArraySize = 500000 # about 4Mb - kMinTreeDepth = 4 - kMaxTreeDepth = 16 - -# Nodes used by a tree of a given size -proc TreeSize(i: int): int = return ((1 shl (i + 1)) - 1) - -# Number of iterations to use for a given tree depth -proc NumIters(i: int): int = - return 2 * TreeSize(kStretchTreeDepth) div TreeSize(i) - -# Build tree top down, assigning to older objects. -proc Populate(iDepth: int, thisNode: PNode) = - if iDepth <= 0: - return - else: - new(thisNode.left) - new(thisNode.right) - Populate(iDepth-1, thisNode.left) - Populate(iDepth-1, thisNode.right) - -# Build tree bottom-up -proc MakeTree(iDepth: int): PNode = - if iDepth <= 0: - new(result) - else: - return newNode(MakeTree(iDepth-1), - MakeTree(iDepth-1)) - -proc PrintDiagnostics() = - var - FreeMemory = getFreeMem() - TotalMemory = getTotalMem() - - echo("Total memory available: " & $TotalMemory & " bytes") - echo("Free memory: " & $FreeMemory & " bytes") - -proc TimeConstruction(depth: int) = - var - root, tempTree: PNode - t: int - iNumIters: int - - iNumIters = NumIters(depth) - - echo("Creating " & $iNumIters & " trees of depth " & $depth) - t = getStartMilsecs() - for i in 0..iNumIters-1: - new(tempTree) - Populate(depth, tempTree) - tempTree = nil - echo("\tTop down construction took " & - $(getStartMilsecs() - t) & "msecs") - t = getStartMilsecs() - for i in 0..iNumIters-1: - tempTree = MakeTree(depth) - tempTree = nil - echo("\tBottom up construction took " & - $(getStartMilsecs() - t) & "msecs") - -type - tMyArray = seq[float] - -proc main() = - var - root, longLivedTree, tempTree: PNode - t: int - myarray: tMyArray - - echo("Garbage Collector Test") - echo(" Stretching memory with a binary tree of depth " & - $kStretchTreeDepth) - PrintDiagnostics() - t = getStartMilsecs() - - # Stretch the memory space quickly - tempTree = MakeTree(kStretchTreeDepth) - tempTree = nil - - # Create a long lived object - echo(" Creating a long-lived binary tree of depth " & - $kLongLivedTreeDepth) - new(longLivedTree) - Populate(kLongLivedTreeDepth, longLivedTree) - - # Create long-lived array, filling half of it - echo(" Creating a long-lived array of " & $kArraySize & " doubles") - myarray = [] - setlength(myarray, kArraySize) - for i in 0..kArraySize div 2 -1: - myarray[i] = 1.0 / toFloat(i) - - PrintDiagnostics() - - var d = kMinTreeDepth - while d <= kMaxTreeDepth: - TimeConstruction(d) - inc(d, 2) - - if longLivedTree == nil or myarray[1000] != 1.0/1000.0: - echo("Failed") - # fake reference to LongLivedTree - # and array to keep them from being optimized away - - var elapsed = getStartMilsecs() - t - PrintDiagnostics() - echo("Completed in " & $elapsed & "ms.") - -main() diff --git a/tests/bench/prof.c b/tests/bench/prof.c deleted file mode 100644 index cd91fa339..000000000 --- a/tests/bench/prof.c +++ /dev/null @@ -1,63 +0,0 @@ -#include <unistd.h> -#include <stdlib.h> -#include <stdio.h> - -/* A very simple profiler. Note that it should be possible to */ -/* get function level information by concatenating this with nm */ -/* output and running the result through the sort utility. */ -/* This assumes that all interesting parts of the executable */ -/* are statically linked. */ - -static size_t buf_size; -static u_short *profil_buf; - -# ifdef __i386__ -# ifndef COMPRESSION -# define COMPRESSION 1 -# endif -# define TEXT_START 0x08000000 -# define PTR_DIGS 8 -# endif -# ifdef __ia64__ -# ifndef COMPRESSION -# define COMPRESSION 8 -# endif -# define TEXT_START 0x4000000000000000 -# define PTR_DIGS 16 -# endif - -extern int etext; - -/* - * Note that the ith entry in the profile buffer corresponds to - * a PC value of TEXT_START + i * COMPRESSION * 2. - * The extra factor of 2 is not apparent from the documentation, - * but it is explicit in the glibc source. - */ - -void init_profiling() -{ - buf_size = ((size_t)(&etext) - TEXT_START + 0x10)/COMPRESSION/2; - profil_buf = calloc(buf_size, sizeof(u_short)); - if (profil_buf == 0) { - fprintf(stderr, "Could not allocate profile buffer\n"); - } - profil(profil_buf, buf_size * sizeof(u_short), - TEXT_START, 65536/COMPRESSION); -} - -void dump_profile() -{ - size_t i; - size_t sum = 0; - for (i = 0; i < buf_size; ++i) { - if (profil_buf[i] != 0) { - fprintf(stderr, "%0*lx\t%d !PROF!\n", - PTR_DIGS, - TEXT_START + i * COMPRESSION * 2, - profil_buf[i]); - sum += profil_buf[i]; - } - } - fprintf(stderr, "Total number of samples was %ld !PROF!\n", sum); -} diff --git a/tests/gc.bpf b/tests/gc.bpf deleted file mode 100644 index e56372389..000000000 --- a/tests/gc.bpf +++ /dev/null @@ -1,9 +0,0 @@ -USEUNIT("morc_gen\gctest.c"); -USEUNIT("..\lib\dlmalloc.c"); -USEUNIT("..\lib\morc_gen\io.c"); -USEUNIT("..\lib\morc_gen\strutils.c"); -USEUNIT("..\lib\morc_gen\system.c"); -//--------------------------------------------------------------------------- -This file is used by the project manager only and should be treated like the project file - - main \ No newline at end of file diff --git a/tests/gc.bpr b/tests/gc.bpr deleted file mode 100644 index 8e72b1d86..000000000 --- a/tests/gc.bpr +++ /dev/null @@ -1,85 +0,0 @@ -<?xml version='1.0' encoding='utf-8' ?> -<!-- C++Builder XML Project --> -<PROJECT> - <MACROS> - <VERSION value="BCB.05.03"/> - <PROJECT value="gc.exe"/> - <OBJFILES value="morc_gen\gctest.obj ..\lib\dlmalloc.obj ..\lib\morc_gen\io.obj - ..\lib\morc_gen\strutils.obj ..\lib\morc_gen\system.obj"/> - <RESFILES value=""/> - <DEFFILE value=""/> - <RESDEPEN value="$(RESFILES)"/> - <LIBFILES value=""/> - <LIBRARIES value=""/> - <SPARELIBS value=""/> - <PACKAGES value="Vcl50.bpi Vclx50.bpi bcbsmp50.bpi dclocx50.bpi bcb2kaxserver50.bpi"/> - <PATHCPP value=".;morc_gen;..\lib;..\lib\morc_gen"/> - <PATHPAS value=".;"/> - <PATHRC value=".;"/> - <PATHASM value=".;"/> - <DEBUGLIBPATH value="$(BCB)\lib\debug"/> - <RELEASELIBPATH value="$(BCB)\lib\release"/> - <LINKER value="tlink32"/> - <USERDEFINES value="_DEBUG"/> - <SYSDEFINES value="NO_STRICT;_NO_VCL;_RTLDLL;USEPACKAGES"/> - <MAINSOURCE value="gc.bpf"/> - <INCLUDEPATH value="..\lib\morc_gen;..\lib;morc_gen;$(BCB)\include;$(BCB)\include\vcl"/> - <LIBPATH value="..\lib\morc_gen;..\lib;morc_gen;$(BCB)\lib\obj;$(BCB)\lib"/> - <WARNINGS value="-w-par"/> - </MACROS> - <OPTIONS> - <CFLAG1 value="-tWC -tWM- -Od -H=$(BCB)\lib\vcl50.csm -Hc -Vx -Ve -X- -r- -a8 -b- -k -y - -v -vi- -c"/> - <PFLAGS value="-$YD -$W -$O- -v -JPHNE -M"/> - <RFLAGS value=""/> - <AFLAGS value="/mx /w2 /zd"/> - <LFLAGS value="-Tpe -ap -D"" -x -Gn -v"/> - </OPTIONS> - <LINKER> - <ALLOBJ value="c0x32.obj $(PACKAGES) $(OBJFILES)"/> - <ALLRES value="$(RESFILES)"/> - <ALLLIB value="$(LIBFILES) $(LIBRARIES) import32.lib cw32i.lib"/> - </LINKER> - <IDEOPTIONS> -[Version Info] -IncludeVerInfo=0 -AutoIncBuild=0 -MajorVer=1 -MinorVer=0 -Release=0 -Build=0 -Debug=0 -PreRelease=0 -Special=0 -Private=0 -DLL=0 -Locale=1031 -CodePage=1252 - -[Version Info Keys] -CompanyName= -FileDescription= -FileVersion=1.0.0.0 -InternalName= -LegalCopyright= -LegalTrademarks= -OriginalFilename= -ProductName= -ProductVersion=1.0.0.0 -Comments= - -[Debugging] -DebugSourceDirs=$(BCB)\source\vcl - -[Parameters] -RunParams= -HostApplication= -RemoteHost= -RemotePath= -RemoteDebug=0 - -[Compiler] -ShowInfoMsgs=0 -LinkDebugVcl=0 - </IDEOPTIONS> -</PROJECT> \ No newline at end of file diff --git a/tests/gctest.nim b/tests/gctest.nim index b0f5ff8ce..60845033c 100644 --- a/tests/gctest.nim +++ b/tests/gctest.nim @@ -6,31 +6,40 @@ import type PNode = ref TNode - TNode = record + TNode {.final.} = object le, ri: PNode data: string - TTable = record + TTable {.final.} = object counter, max: int data: seq[string] - TBNode = record + TBNode {.final.} = object other: PNode # a completely different tree data: string sons: seq[TBNode] # directly embedded! t: TTable - TCaseKind = enum nkStr, nkList + TCaseKind = enum nkStr, nkWhole, nkList PCaseNode = ref TCaseNode - TCaseNode = record + TCaseNode {.final.} = object case kind: TCaseKind of nkStr: data: string of nkList: sons: seq[PCaseNode] + else: unused: seq[string] + +var + flip: int proc newCaseNode(data: string): PCaseNode = new(result) - result.kind = nkStr - result.data = data + if flip == 0: + result.kind = nkStr + result.data = data + else: + result.kind = nkWhole + result.unused = ["", "abc", "abdc"] + flip = 1 - flip proc newCaseNode(a, b: PCaseNode): PCaseNode = new(result) @@ -44,7 +53,8 @@ proc caseTree(lvl: int = 0): PCaseNode = proc finalizeBNode(n: TBNode) = writeln(stdout, n.data) proc finalizeNode(n: PNode) = assert(n != nil) - writeln(stdout, n.data) + if isNil(n.data): writeln(stdout, "nil!") + else: writeln(stdout, n.data) var id: int = 1 diff --git a/tests/hallo.bpf b/tests/hallo.bpf deleted file mode 100644 index 530b73a54..000000000 --- a/tests/hallo.bpf +++ /dev/null @@ -1,10 +0,0 @@ -USEUNIT("rod_gen\thallo.c"); -USEUNIT("..\lib\rod_gen\os.c"); -USEUNIT("..\lib\rod_gen\strutils.c"); -USEUNIT("..\lib\rod_gen\system.c"); -USEUNIT("..\lib\rod_gen\times.c"); -USEUNIT("..\lib\dlmalloc.c"); -//--------------------------------------------------------------------------- -This file is used by the project manager only and should be treated like the project file - - main \ No newline at end of file diff --git a/tests/hallo.bpr b/tests/hallo.bpr deleted file mode 100644 index 9ba49b99c..000000000 --- a/tests/hallo.bpr +++ /dev/null @@ -1,102 +0,0 @@ -<?xml version='1.0' encoding='utf-8' ?> -<!-- C++Builder XML Project --> -<PROJECT> - <MACROS> - <VERSION value="BCB.05.03"/> - <PROJECT value="hallo.exe"/> - <OBJFILES value="rod_gen\thallo.obj ..\lib\rod_gen\os.obj ..\lib\rod_gen\strutils.obj - ..\lib\rod_gen\system.obj ..\lib\rod_gen\times.obj ..\lib\dlmalloc.obj"/> - <RESFILES value=""/> - <DEFFILE value=""/> - <RESDEPEN value="$(RESFILES)"/> - <LIBFILES value=""/> - <LIBRARIES value=""/> - <SPARELIBS value=""/> - <PACKAGES value="Vcl50.bpi Vclx50.bpi bcbsmp50.bpi dclocx50.bpi bcb2kaxserver50.bpi"/> - <PATHCPP value=".;rod_gen;..\lib\rod_gen;..\lib"/> - <PATHPAS value=".;"/> - <PATHRC value=".;"/> - <PATHASM value=".;"/> - <DEBUGLIBPATH value="$(BCB)\lib\debug"/> - <RELEASELIBPATH value="$(BCB)\lib\release"/> - <LINKER value="tlink32"/> - <USERDEFINES value="_DEBUG"/> - <SYSDEFINES value="NO_STRICT;_NO_VCL;_RTLDLL;USEPACKAGES"/> - <MAINSOURCE value="hallo.bpf"/> - <INCLUDEPATH value="..\lib\rod_gen;rod_gen;$(BCB)\include;$(BCB)\include\vcl;..\lib"/> - <LIBPATH value="..\lib;..\lib\rod_gen;rod_gen;$(BCB)\lib\obj;$(BCB)\lib"/> - <WARNINGS value="-w-par"/> - </MACROS> - <OPTIONS> - <CFLAG1 value="-Od -H=$(BCB)\lib\vcl50.csm -Hc -Vx -Ve -X- -r- -a8 -b- -k -y -v -vi- -tWC - -tWM- -c"/> - <PFLAGS value="-$YD -$W -$O- -v -JPHNE -M"/> - <RFLAGS value=""/> - <AFLAGS value="/mx /w2 /zd"/> - <LFLAGS value="-D"" -ap -Tpe -x -Gn -v"/> - </OPTIONS> - <LINKER> - <ALLOBJ value="c0x32.obj $(PACKAGES) $(OBJFILES)"/> - <ALLRES value="$(RESFILES)"/> - <ALLLIB value="$(LIBFILES) $(LIBRARIES) import32.lib cw32i.lib"/> - </LINKER> - <IDEOPTIONS> -[Version Info] -IncludeVerInfo=0 -AutoIncBuild=0 -MajorVer=1 -MinorVer=0 -Release=0 -Build=0 -Debug=0 -PreRelease=0 -Special=0 -Private=0 -DLL=0 -Locale=1031 -CodePage=1252 - -[Version Info Keys] -CompanyName= -FileDescription= -FileVersion=1.0.0.0 -InternalName= -LegalCopyright= -LegalTrademarks= -OriginalFilename= -ProductName= -ProductVersion=1.0.0.0 -Comments= - -[HistoryLists\hlIncludePath] -Count=2 -Item0=..\lib\rod_gen;rod_gen;$(BCB)\include;$(BCB)\include\vcl;E:\nimrod\lib -Item1=..\lib\rod_gen;rod_gen;$(BCB)\include;$(BCB)\include\vcl - -[HistoryLists\hlLibraryPath] -Count=1 -Item0=..\lib\rod_gen;rod_gen;$(BCB)\lib\obj;$(BCB)\lib - -[HistoryLists\hlDebugSourcePath] -Count=1 -Item0=$(BCB)\source\vcl - -[HistoryLists\hlConditionals] -Count=1 -Item0=_DEBUG - -[Debugging] -DebugSourceDirs=$(BCB)\source\vcl - -[Parameters] -RunParams= -HostApplication= -RemoteHost= -RemotePath= -RemoteDebug=0 - -[Compiler] -ShowInfoMsgs=0 -LinkDebugVcl=0 - </IDEOPTIONS> -</PROJECT> \ No newline at end of file diff --git a/tests/iotest.bpf b/tests/iotest.bpf deleted file mode 100644 index 2294271cc..000000000 --- a/tests/iotest.bpf +++ /dev/null @@ -1,10 +0,0 @@ -USEUNIT("tio.c"); -USEUNIT("..\lib\refcgc.c"); -USEUNIT("..\lib\io.c"); -USEUNIT("..\lib\morbase.c"); -USEUNIT("..\lib\morlib.c"); -//--------------------------------------------------------------------------- -This file is used by the project manager only and should be treated like the project file - - -main \ No newline at end of file diff --git a/tests/iotest.bpr b/tests/iotest.bpr deleted file mode 100644 index 187918550..000000000 --- a/tests/iotest.bpr +++ /dev/null @@ -1,84 +0,0 @@ -<?xml version='1.0' encoding='utf-8' ?> -<!-- C++Builder XML Project --> -<PROJECT> - <MACROS> - <VERSION value="BCB.05.03"/> - <PROJECT value="iotest.exe"/> - <OBJFILES value="tio.obj ..\lib\refcgc.obj ..\lib\io.obj ..\lib\morbase.obj ..\lib\morlib.obj"/> - <RESFILES value=""/> - <DEFFILE value=""/> - <RESDEPEN value="$(RESFILES)"/> - <LIBFILES value=""/> - <LIBRARIES value=""/> - <SPARELIBS value=""/> - <PACKAGES value="Vcl50.bpi Vclx50.bpi bcbsmp50.bpi dclocx50.bpi bcb2kaxserver50.bpi"/> - <PATHCPP value=".;..\lib"/> - <PATHPAS value=".;"/> - <PATHRC value=".;"/> - <PATHASM value=".;"/> - <DEBUGLIBPATH value="$(BCB)\lib\debug"/> - <RELEASELIBPATH value="$(BCB)\lib\release"/> - <LINKER value="tlink32"/> - <USERDEFINES value="_DEBUG"/> - <SYSDEFINES value="NO_STRICT;_NO_VCL;_RTLDLL;USEPACKAGES"/> - <MAINSOURCE value="iotest.bpf"/> - <INCLUDEPATH value="..\lib;$(BCB)\include;$(BCB)\include\vcl"/> - <LIBPATH value="..\lib;$(BCB)\lib\obj;$(BCB)\lib"/> - <WARNINGS value="-w-par"/> - </MACROS> - <OPTIONS> - <CFLAG1 value="-Od -H=$(BCB)\lib\vcl50.csm -Hc -w- -Vx -Ve -X- -r- -a8 -b- -k -y -v -vi- - -tWC -tWM- -c"/> - <PFLAGS value="-$YD -$W -$O- -v -JPHNE -M"/> - <RFLAGS value=""/> - <AFLAGS value="/mx /w2 /zd"/> - <LFLAGS value="-D"" -ap -Tpe -x -Gn -v"/> - </OPTIONS> - <LINKER> - <ALLOBJ value="c0x32.obj $(PACKAGES) $(OBJFILES)"/> - <ALLRES value="$(RESFILES)"/> - <ALLLIB value="$(LIBFILES) $(LIBRARIES) import32.lib cw32i.lib"/> - </LINKER> - <IDEOPTIONS> -[Version Info] -IncludeVerInfo=0 -AutoIncBuild=0 -MajorVer=1 -MinorVer=0 -Release=0 -Build=0 -Debug=0 -PreRelease=0 -Special=0 -Private=0 -DLL=0 -Locale=1031 -CodePage=1252 - -[Version Info Keys] -CompanyName= -FileDescription= -FileVersion=1.0.0.0 -InternalName= -LegalCopyright= -LegalTrademarks= -OriginalFilename= -ProductName= -ProductVersion=1.0.0.0 -Comments= - -[Debugging] -DebugSourceDirs=$(BCB)\source\vcl - -[Parameters] -RunParams= -HostApplication= -RemoteHost= -RemotePath= -RemoteDebug=0 - -[Compiler] -ShowInfoMsgs=0 -LinkDebugVcl=0 - </IDEOPTIONS> -</PROJECT> \ No newline at end of file diff --git a/tests/minit.nim b/tests/minit.nim index ce4cd23fa..d3b4b0be1 100644 --- a/tests/minit.nim +++ b/tests/minit.nim @@ -1,6 +1,2 @@ # Test the new initialization for modules - -import - io - write(stdout, "Hallo from module! ") diff --git a/tests/mopaque.nim b/tests/mopaque.nim index 17b8bba62..b7c5180fd 100644 --- a/tests/mopaque.nim +++ b/tests/mopaque.nim @@ -1,5 +1,5 @@ type - TLexer* = record + TLexer* {.final.} = object line*: int filename*: string buffer: cstring diff --git a/tests/rectest/rectest.nim b/tests/rectest/rectest.nim deleted file mode 100644 index f08306cfd..000000000 --- a/tests/rectest/rectest.nim +++ /dev/null @@ -1,6 +0,0 @@ -# Test the error message - -proc main() = - main() - -main() diff --git a/tests/scantest.nim b/tests/scantest.nim index 559938d8e..c9779c762 100644 --- a/tests/scantest.nim +++ b/tests/scantest.nim @@ -12,7 +12,7 @@ import lexbase, os, strutils type - TMyRec = record # describes a record + TMyRec {.final.} = object x, y: int # coordinates c: char # a character a: int32 # an integer diff --git a/tests/seqcon.bpf b/tests/seqcon.bpf deleted file mode 100644 index 0f4cad131..000000000 --- a/tests/seqcon.bpf +++ /dev/null @@ -1,8 +0,0 @@ -USEUNIT("tseqcon.c"); -USEUNIT("..\lib\io.c"); -USEUNIT("..\lib\morsys.c"); -//--------------------------------------------------------------------------- -This file is used by the project manager only and should be treated like the project file - - -main \ No newline at end of file diff --git a/tests/seqcon.bpr b/tests/seqcon.bpr deleted file mode 100644 index 9160b20ee..000000000 --- a/tests/seqcon.bpr +++ /dev/null @@ -1,84 +0,0 @@ -<?xml version='1.0' encoding='utf-8' ?> -<!-- C++Builder XML Project --> -<PROJECT> - <MACROS> - <VERSION value="BCB.05.03"/> - <PROJECT value="seqcon.exe"/> - <OBJFILES value="tseqcon.obj ..\lib\io.obj ..\lib\morsys.obj"/> - <RESFILES value=""/> - <DEFFILE value=""/> - <RESDEPEN value="$(RESFILES)"/> - <LIBFILES value=""/> - <LIBRARIES value=""/> - <SPARELIBS value=""/> - <PACKAGES value="Vcl50.bpi Vclx50.bpi bcbsmp50.bpi dclocx50.bpi bcb2kaxserver50.bpi"/> - <PATHCPP value=".;..\lib"/> - <PATHPAS value=".;"/> - <PATHRC value=".;"/> - <PATHASM value=".;"/> - <DEBUGLIBPATH value="$(BCB)\lib\debug"/> - <RELEASELIBPATH value="$(BCB)\lib\release"/> - <LINKER value="tlink32"/> - <USERDEFINES value="_DEBUG"/> - <SYSDEFINES value="NO_STRICT;_NO_VCL;_RTLDLL;USEPACKAGES"/> - <MAINSOURCE value="seqcon.bpf"/> - <INCLUDEPATH value="..\lib;$(BCB)\include;$(BCB)\include\vcl"/> - <LIBPATH value="..\lib;$(BCB)\lib\obj;$(BCB)\lib"/> - <WARNINGS value="-w-par"/> - </MACROS> - <OPTIONS> - <CFLAG1 value="-Od -H=$(BCB)\lib\vcl50.csm -Hc -Vx -Ve -X- -r- -pr -a8 -b- -k -y -v -vi- - -tWC -tWM- -c"/> - <PFLAGS value="-$YD -$W -$O- -v -JPHNE -M"/> - <RFLAGS value=""/> - <AFLAGS value="/mx /w2 /zd"/> - <LFLAGS value="-D"" -ap -Tpe -x -Gn -v"/> - </OPTIONS> - <LINKER> - <ALLOBJ value="c0x32.obj $(PACKAGES) $(OBJFILES)"/> - <ALLRES value="$(RESFILES)"/> - <ALLLIB value="$(LIBFILES) $(LIBRARIES) import32.lib cw32i.lib"/> - </LINKER> - <IDEOPTIONS> -[Version Info] -IncludeVerInfo=0 -AutoIncBuild=0 -MajorVer=1 -MinorVer=0 -Release=0 -Build=0 -Debug=0 -PreRelease=0 -Special=0 -Private=0 -DLL=0 -Locale=1031 -CodePage=1252 - -[Version Info Keys] -CompanyName= -FileDescription= -FileVersion=1.0.0.0 -InternalName= -LegalCopyright= -LegalTrademarks= -OriginalFilename= -ProductName= -ProductVersion=1.0.0.0 -Comments= - -[Debugging] -DebugSourceDirs=$(BCB)\source\vcl - -[Parameters] -RunParams= -HostApplication= -RemoteHost= -RemotePath= -RemoteDebug=0 - -[Compiler] -ShowInfoMsgs=0 -LinkDebugVcl=0 - </IDEOPTIONS> -</PROJECT> \ No newline at end of file diff --git a/tests/tack.nim b/tests/tack.nim index 254f37d3c..59535e547 100644 --- a/tests/tack.nim +++ b/tests/tack.nim @@ -1,8 +1,5 @@ # the Ackermann function -import - io - proc ack(x, y: int): int = if x != 0: if y != 0: diff --git a/tests/tarray.nim b/tests/tarray.nim index b2a6f0011..5eca2cfa1 100644 --- a/tests/tarray.nim +++ b/tests/tarray.nim @@ -1,13 +1,8 @@ # simple check for one dimensional arrays -import - io - type TMyArray = array[0..2, int] - TMyRecord = record - x, y: int - + TMyRecord = tuple[x, y: int] proc sum(a: TMyarray): int = result = 0 diff --git a/tests/tassert.nim b/tests/tassert.nim index cb53153be..1eff23502 100644 --- a/tests/tassert.nim +++ b/tests/tassert.nim @@ -1,8 +1,5 @@ # test assert and exception handling -import - io - proc callB() = assert(False) proc callA() = callB() proc callC() = callA() @@ -10,10 +7,10 @@ proc callC() = callA() try: callC() except EAssertionFailed: - io.write(stdout, "assertion failure!\n") + write(stdout, "assertion failure!\n") except: - io.write(stdout, "unknown exception!\n") + write(stdout, "unknown exception!\n") finally: - io.write(stdout, "this shall be always written\n") + system.write(stdout, "this shall be always written\n") assert(false) diff --git a/tests/tassign.nim b/tests/tassign.nim index 8f98ad0f3..d5f846502 100644 --- a/tests/tassign.nim +++ b/tests/tassign.nim @@ -1,10 +1,7 @@ # Test the assignment operator for complex types which need RTTI -import - io - type - TRec = record + TRec = object x, y: int s: string seq: seq[string] @@ -19,15 +16,15 @@ proc test() = a.s = "Hallo!" a.seq = ["abc", "def", "ghi", "jkl"] a.arr = [] - setLength(a.arr, 4) + setLen(a.arr, 4) a.arr[0] = [] a.arr[1] = [] b = a # perform a deep copy here! b.seq = ["xyz", "huch", "was", "soll"] - writeln(stdout, length(a.seq)) + writeln(stdout, len(a.seq)) writeln(stdout, a.seq[3]) - writeln(stdout, length(b.seq)) + writeln(stdout, len(b.seq)) writeln(stdout, b.seq[3]) writeln(stdout, b.y) diff --git a/tests/tblock1.nim b/tests/tblock1.nim index 3119be9c1..729bfd3e7 100644 --- a/tests/tblock1.nim +++ b/tests/tblock1.nim @@ -1,9 +1,6 @@ # check for forward label and # for failure when label is not declared -import - io - proc main = block endLess: break endLess diff --git a/tests/tconstr1.nim b/tests/tconstr1.nim index 0ff7def97..994e55b86 100644 --- a/tests/tconstr1.nim +++ b/tests/tconstr1.nim @@ -1,14 +1,12 @@ # Test array, record constructors -import - io - type - TComplexRecord = record - s: string - x, y: int - z: float + TComplexRecord = tuple[ + s: string, + x, y: int, + z: float, chars: set[Char] + ] proc testSem = var diff --git a/tests/tconstr2.nim b/tests/tconstr2.nim index 9dc64e59d..4c27bd833 100644 --- a/tests/tconstr2.nim +++ b/tests/tconstr2.nim @@ -1,11 +1,12 @@ # Test array, record constructors type - TComplexRecord = record - s: string - x, y: int - z: float - chars: set[char] + TComplexRecord = tuple[ + s: string, + x, y: int, + z: float, + chars: set[char], + ] const things: array [0.., TComplexRecord] = [ diff --git a/tests/tcopy.nim b/tests/tcopy.nim index efbe65ea4..81d72c7f2 100644 --- a/tests/tcopy.nim +++ b/tests/tcopy.nim @@ -1,7 +1,7 @@ # tests the copy proc import - strutils, io + strutils proc main() = const diff --git a/tests/tformat.nim b/tests/tformat.nim index 01be0df3a..aba35504b 100644 --- a/tests/tformat.nim +++ b/tests/tformat.nim @@ -1,6 +1,6 @@ # Tests the new format proc (including the & and &= operators) -import strutils, io +import strutils echo("Hi $1! How do you feel, $2?\n" % ["Andreas", "Rumpf"]) #OUT Hi Andreas! How do you feel, Rumpf? diff --git a/tests/tforwty.nim b/tests/tforwty.nim index 3c43819aa..0f1d3697f 100644 --- a/tests/tforwty.nim +++ b/tests/tforwty.nim @@ -3,7 +3,7 @@ type PSym = ref TSym - TSym = record + TSym = object next: PSym var s: PSym diff --git a/tests/tforwty2.nim b/tests/tforwty2.nim index 1e1bb7f55..32f86f135 100644 --- a/tests/tforwty2.nim +++ b/tests/tforwty2.nim @@ -6,14 +6,14 @@ when defined(windows): type PSDL_semaphore = ptr TSDL_semaphore - TSDL_semaphore = record + TSDL_semaphore {.final.} = object id: uint32 count: UInt32 elif defined(linux): type PSDL_semaphore = ptr TSDL_semaphore - TSDL_semaphore = record + TSDL_semaphore {.final.} = object sem: Pointer #PSem_t; when not defined(USE_NAMED_SEMAPHORES): sem_data: int diff --git a/tests/tgeneric.nim b/tests/tgeneric.nim deleted file mode 100644 index 276fe810d..000000000 --- a/tests/tgeneric.nim +++ /dev/null @@ -1,96 +0,0 @@ -struct vector3d -{ - float V[3]; - inline float Evaluate( const int I ) const { return V[I]; } - - template< class ta > - inline const vector3d& operator = ( const ta& Exp ) - { - V[0] = Exp.Evaluate( 0 ); - V[1] = Exp.Evaluate( 1 ); - V[2] = Exp.Evaluate( 2 ); - } -}; - -type - TVector3D = record - v: array [0..2, float] - - TSum[A, B] = record - TVecExpr2[A, B, op] = record - -proc eval(a: TVector3d, i: int): float = a.v[i] -proc eval[T, S](a: T, b: S, i: int): float = eval(a, i) + eval(b, i) - -proc `+` [T, S](a, b: TVector3d): TSum[T, S] = return vecExpr2[a, b, TSum] - -proc `=` [T](a: var TVector3d, b: T) = - a.v[0] = eval(b, 0) - a.v[1] = eval(b, 1) - a.v[2] = eval(b, 2) - -macro `=` (a: var TVector3d, b: expr) = - -proc doSomething(a, b: TVector3d): TVector3d = - eliminateTemps: - result = a +^ b +^ a *^ a *^ 7 - # result = a - # result +^= b - # tmp = a - # tmp *^= a - # tmp *^= 7 - # result +^= tmp - -macro vectorOptimizeExpr(n: expr): stmt = - # load the expr n[1] into n[0] - var e = n[1] - if binOp(e) and Operator(e) == "+^": - var m = flattenTree(n[1]) - result = newAst(nkStmtList) # ``newAst`` is built-in for any macro - add(result, newAst(nkAsgn, n[0], m[1])) - var tmp: PNode = nil - for i in 2..m.len-1: - if BinOp(m[i]): - if tmp = nil: tmp = getTemp() # reuse temporary if possible - vectorOptimizeExpr(newAst(nkAsgn, tmp, m[i])) - add(result, newAst(nkCall, Operator(m) & "=", n[0], tmp)) - else: - add(result, newAst(nkCall, Operator(m) & "=", n[0], m[i])) - -macro eliminateTemps(s) {.check.} = - case s.kind - of nkAsgnStmt: - result = vectorOptimizeExpr(s) - else: - result = s - for i in 0..s.sons.len-1: result[i] = eliminateTemps(s[i]) - -struct sum -{ - template< class ta, class tb > - static inline float Evaluate( const int I, const ta& A, const tb& B ) - { return A.Evaluate( I ) + B.Evaluate( I ); } -}; - - - -template< class ta_a, class ta_b, class ta_eval > -class vecexp_2 -{ - const ta_a Arg1; - const ta_b Arg2; - -public: - inline vecexp_2( const ta_a& A1, const ta_b& A2 ) - : Arg1( A1 ), Arg2( A2 ) {} - inline const float Evaluate ( const int I ) const - { return ta_eval::Evaluate( I, Arg1, Arg2 ); } -}; - - -template< class ta, class tb > inline -vecexp_2< ta, tb, sum > -inline operator + ( const ta& A, const tb& B ) -{ - return vecexp_2< const ta, const tb, sum >( A, B ); -} \ No newline at end of file diff --git a/tests/thallo.dot b/tests/thallo.dot deleted file mode 100644 index d75155a10..000000000 --- a/tests/thallo.dot +++ /dev/null @@ -1,6 +0,0 @@ -digraph thallo { -times -> strutils; -os -> strutils; -os -> times; -thallo -> os; -} diff --git a/tests/thallo.nim b/tests/thallo.nim index d8c6b3bef..b804dba1e 100644 --- a/tests/thallo.nim +++ b/tests/thallo.nim @@ -11,9 +11,28 @@ proc fac[T](x: T): T = if x <= 1: return 1 else: return x * fac(x-1) +macro macrotest(n: expr): stmt = + expectKind(n, nnkCall) + expectMinLen(n, 2) + result = newNimNode(nnkStmtList, n) + for i in 2..n.len-1: + result.add(newCall("write", n[1], n[i])) + result.add(newCall("writeln", n[1], newStrLitNode(""))) + +macro debug(n: expr): stmt = + result = newNimNode(nnkStmtList, n) + for i in 1..n.len-1: + result.add(newCall("write", newIdentNode("stdout"), toStrLit(n[i]))) + result.add(newCall("write", newIdentNode("stdout"), newStrLitNode(": "))) + result.add(newCall("writeln", newIdentNode("stdout"), n[i])) + +macrotest(stdout, "finally", 4, 5, "variable", "argument lists") +macrotest(stdout) + #GC_disable() echo("This was compiled by Nimrod version " & system.nimrodVersion) +writeln(stdout, "Hallo", " World", "!") echo(["a", "b", "c", "d"].len) for x in items(["What's", "your", "name", "?"]): @@ -21,6 +40,13 @@ for x in items(["What's", "your", "name", "?"]): var `name` = readLine(stdin) {.breakpoint.} echo("Hi " & thallo.name & "!\n") +debug(name) + +var testseq: seq[string] = [ "a", "b", "c", "d"] +echo(repr(testseq)) + +var dummy = "hallo" +echo(copy(dummy, 2, 3)) for i in 2..6: for j in countdown(i+4, 2): diff --git a/tests/tillrec.nim b/tests/tillrec.nim index 7c3e5f628..eba04a96a 100644 --- a/tests/tillrec.nim +++ b/tests/tillrec.nim @@ -1,11 +1,11 @@ # test illegal recursive types type - TLegal = record + TLegal {.final.} = object x: int kids: seq[TLegal] - TIllegal = record + TIllegal {.final.} = object y: Int x: array[0..3, TIllegal] #ERROR_MSG illegal recursion in type 'TIllegal' diff --git a/tests/tinit.nim b/tests/tinit.nim index e882fa921..85475ce94 100644 --- a/tests/tinit.nim +++ b/tests/tinit.nim @@ -1,6 +1,6 @@ # Test the new init section in modules -import minit, io +import minit write(stdout, "Hallo from main module!\n") #OUT Hallo from module! Hallo from main module! diff --git a/tests/tinout.nim b/tests/tinout.nim index fb7f3b8fd..b4fe2fb10 100644 --- a/tests/tinout.nim +++ b/tests/tinout.nim @@ -1,6 +1,6 @@ # Test in out checking for parameters -proc abc(x: out int) = +proc abc(x: var int) = x = 0 proc b() = diff --git a/tests/tio.nim b/tests/tio.nim index ce024f754..014c32d9f 100644 --- a/tests/tio.nim +++ b/tests/tio.nim @@ -1,10 +1,7 @@ # test the file-IO -import - io - proc main() = - for line in lines("thallo.mor"): + for line in lines("thallo.nim"): writeln(stdout, line) main() diff --git a/tests/titer.nim b/tests/titer.nim index 736ba3155..536e2f60d 100644 --- a/tests/titer.nim +++ b/tests/titer.nim @@ -1,8 +1,5 @@ # Test the new iterators -import - io - iterator xrange(fromm, to: int, step = 1): (a: int) = a = fromm while a <= to: diff --git a/tests/tlastmod.nim b/tests/tlastmod.nim index af00e5bf4..b84147c62 100644 --- a/tests/tlastmod.nim +++ b/tests/tlastmod.nim @@ -1,7 +1,7 @@ # test the new LastModificationTime() proc import - io, os, times + os, times proc main() = var diff --git a/tests/tloops.nim b/tests/tloops.nim index de3f4a777..3d03256ad 100644 --- a/tests/tloops.nim +++ b/tests/tloops.nim @@ -1,8 +1,5 @@ # Test nested loops and some other things -import - io - proc andTest() = var a = 0 == 5 and 6 == 6 @@ -60,7 +57,7 @@ proc Foo(n: int): int = while b: a = a + 3 a = a + 5 - io.write(stdout, "Hallo!") + write(stdout, "Hallo!") # We should come till here :-) diff --git a/tests/tlowhigh.nim b/tests/tlowhigh.nim index 6553da2b5..79f5c5b95 100644 --- a/tests/tlowhigh.nim +++ b/tests/tlowhigh.nim @@ -1,8 +1,5 @@ # Test the magic low() and high() procs -import - io - type myEnum = enum e1, e2, e3, e4, e5 diff --git a/tests/tmath.nim b/tests/tmath.nim index d640f04d9..5a10cafb3 100644 --- a/tests/tmath.nim +++ b/tests/tmath.nim @@ -1,8 +1,5 @@ # tests for the interpreter -import - io - proc loops(a: out int) = nil #var diff --git a/tests/tnestif.nim b/tests/tnestif.nim index 673aca062..558fe8d07 100644 --- a/tests/tnestif.nim +++ b/tests/tnestif.nim @@ -1,8 +1,5 @@ # test nested ifs -import - io - var x, y: int x = 2 diff --git a/tests/tnew.bpf b/tests/tnew.bpf deleted file mode 100644 index ab5aa4dbe..000000000 --- a/tests/tnew.bpf +++ /dev/null @@ -1,10 +0,0 @@ -USEUNIT("tnew.c"); -USEUNIT("..\lib\io.c"); -USEUNIT("..\lib\markstck.c"); -USEUNIT("..\lib\morsys.c"); -USEUNIT("..\lib\dlmalloc.c"); -//--------------------------------------------------------------------------- -This file is used by the project manager only and should be treated like the project file - - -main \ No newline at end of file diff --git a/tests/tnew.bpr b/tests/tnew.bpr deleted file mode 100644 index 3a7b2e0bf..000000000 --- a/tests/tnew.bpr +++ /dev/null @@ -1,84 +0,0 @@ -<?xml version='1.0' encoding='utf-8' ?> -<!-- C++Builder XML Project --> -<PROJECT> - <MACROS> - <VERSION value="BCB.05.03"/> - <PROJECT value="tnew.exe"/> - <OBJFILES value="tnew.obj ..\lib\io.obj ..\lib\markstck.obj ..\lib\morsys.obj - ..\lib\dlmalloc.obj"/> - <RESFILES value=""/> - <DEFFILE value=""/> - <RESDEPEN value="$(RESFILES)"/> - <LIBFILES value=""/> - <LIBRARIES value=""/> - <SPARELIBS value=""/> - <PACKAGES value="Vcl50.bpi Vclx50.bpi bcbsmp50.bpi dclocx50.bpi bcb2kaxserver50.bpi"/> - <PATHCPP value=".;..\lib"/> - <PATHPAS value=".;"/> - <PATHRC value=".;"/> - <PATHASM value=".;"/> - <DEBUGLIBPATH value="$(BCB)\lib\debug"/> - <RELEASELIBPATH value="$(BCB)\lib\release"/> - <LINKER value="tlink32"/> - <USERDEFINES value="_DEBUG"/> - <SYSDEFINES value="NO_STRICT;_NO_VCL;_RTLDLL;USEPACKAGES"/> - <MAINSOURCE value="tnew.bpf"/> - <INCLUDEPATH value="..\lib;$(BCB)\include;$(BCB)\include\vcl"/> - <LIBPATH value="..\lib;$(BCB)\lib\obj;$(BCB)\lib"/> - <WARNINGS value="-w-par"/> - </MACROS> - <OPTIONS> - <CFLAG1 value="-Od -Vx -Ve -X- -r- -pr -a8 -b- -k -y -v -vi- -tWC -tWM- -c"/> - <PFLAGS value="-$YD -$W -$O- -v -JPHNE -M"/> - <RFLAGS value=""/> - <AFLAGS value="/mx /w2 /zd"/> - <LFLAGS value="-D"" -ap -Tpe -x -Gn -v"/> - </OPTIONS> - <LINKER> - <ALLOBJ value="c0x32.obj $(PACKAGES) $(OBJFILES)"/> - <ALLRES value="$(RESFILES)"/> - <ALLLIB value="$(LIBFILES) $(LIBRARIES) import32.lib cw32i.lib"/> - </LINKER> - <IDEOPTIONS> -[Version Info] -IncludeVerInfo=0 -AutoIncBuild=0 -MajorVer=1 -MinorVer=0 -Release=0 -Build=0 -Debug=0 -PreRelease=0 -Special=0 -Private=0 -DLL=0 -Locale=1031 -CodePage=1252 - -[Version Info Keys] -CompanyName= -FileDescription= -FileVersion=1.0.0.0 -InternalName= -LegalCopyright= -LegalTrademarks= -OriginalFilename= -ProductName= -ProductVersion=1.0.0.0 -Comments= - -[Debugging] -DebugSourceDirs=$(BCB)\source\vcl - -[Parameters] -RunParams= -HostApplication= -RemoteHost= -RemotePath= -RemoteDebug=0 - -[Compiler] -ShowInfoMsgs=0 -LinkDebugVcl=0 - </IDEOPTIONS> -</PROJECT> \ No newline at end of file diff --git a/tests/tobject2.nim b/tests/tobject2.nim index 2853adc28..e8e932422 100644 --- a/tests/tobject2.nim +++ b/tests/tobject2.nim @@ -1,8 +1,5 @@ # Tests the object implementation -import - io - type TPoint2d = object x, y: int diff --git a/tests/tobjects.nim b/tests/tobjects.nim index 54e1bd3ac..633c9d6af 100644 --- a/tests/tobjects.nim +++ b/tests/tobjects.nim @@ -1,6 +1,3 @@ -import - io - type TBase = object x, y: int diff --git a/tests/toverflw.nim b/tests/toverflw.nim index 97234d702..c8f194e68 100644 --- a/tests/toverflw.nim +++ b/tests/toverflw.nim @@ -1,8 +1,5 @@ # Tests emc's ability to detect overflows -import - io - {.push overflowChecks: on.} var diff --git a/tests/toverl.nim b/tests/toverl.nim index 469cfb934..1a571ce12 100644 --- a/tests/toverl.nim +++ b/tests/toverl.nim @@ -1,7 +1,7 @@ # Test for overloading type - TNone {.export: "_NONE".} = record + TNone {.export: "_NONE", final.} = object proc TNone(a, b: int) = nil #ERROR_MSG attempt to redefine 'TNone' diff --git a/tests/toverlop.nim b/tests/toverlop.nim index 038760ae5..037da24ee 100644 --- a/tests/toverlop.nim +++ b/tests/toverlop.nim @@ -1,8 +1,5 @@ # Test operator overloading -import - io - proc % (a, b: int): int = return a mod b diff --git a/tests/tovfint.nim b/tests/tovfint.nim index 223e78331..91eda8d0b 100644 --- a/tests/tovfint.nim +++ b/tests/tovfint.nim @@ -1,11 +1,8 @@ # this tests the new overflow literals -import - io - var i: int -i = cast[int](0xffffffff) +i = int(0xffffffff) when defined(cpu64): if i == 4294967295: write(stdout, "works!\n") diff --git a/tests/tpos.nim b/tests/tpos.nim index 9d3223d24..114d39c05 100644 --- a/tests/tpos.nim +++ b/tests/tpos.nim @@ -1,8 +1,5 @@ # test this particular function -import - io - proc mypos(sub, s: string, start: int = 0): int = var i, j, M, N: int diff --git a/tests/tprep.nim b/tests/tprep.nim index 3e8068872..999b2f57f 100644 --- a/tests/tprep.nim +++ b/tests/tprep.nim @@ -1,7 +1,7 @@ # Test the features that used to belong to the preprocessor import - io, times + times {.warning: "This is only a test warning!".} diff --git a/tests/tprocvar.nim b/tests/tprocvar.nim index da757f682..ec23dcb1d 100644 --- a/tests/tprocvar.nim +++ b/tests/tprocvar.nim @@ -1,8 +1,5 @@ # test variables of type proc -import - io - var x: proc (a, b: int): int {.cdecl.} diff --git a/tests/tpush.nim b/tests/tpush.nim index c1be04ec7..5fb411a79 100644 --- a/tests/tpush.nim +++ b/tests/tpush.nim @@ -1,8 +1,5 @@ # test the new pragmas -import - io - {.push warnings: off, hints: off.} proc noWarning() = var diff --git a/tests/tquit.nim b/tests/tquit.nim index fedaa58b4..d4dc1522d 100644 --- a/tests/tquit.nim +++ b/tests/tquit.nim @@ -1,8 +1,5 @@ # Test the new beforeQuit variable: -import - io - proc myExit() {.noconv.} = write(stdout, "just exiting...\n") diff --git a/tests/treadln.nim b/tests/treadln.nim index 3968f02d0..473eb1eaa 100644 --- a/tests/treadln.nim +++ b/tests/treadln.nim @@ -1,9 +1,6 @@ # test the improved readline handling that does not care whether its # Macintosh, Unix or Windows text format. -import - io - var inp: tTextFile line: string diff --git a/tests/trectype.nim b/tests/trectype.nim index 4582d6d41..8e68767b5 100644 --- a/tests/trectype.nim +++ b/tests/trectype.nim @@ -6,7 +6,7 @@ type TA = array [0..2, PA] PRec = ref TRec - TRec = record + TRec {.final.} = object a, b: TA P1 = ref T1 diff --git a/tests/trefs.nim b/tests/trefs.nim index 138d3eb93..ab3934088 100644 --- a/tests/trefs.nim +++ b/tests/trefs.nim @@ -1,8 +1,5 @@ # test for ref types (including refs to procs) -import - io - type TProc = proc (a, b: int): int {.stdcall.} diff --git a/tests/tregex.nim b/tests/tregex.nim index 344f330df..48798aa4f 100644 --- a/tests/tregex.nim +++ b/tests/tregex.nim @@ -2,7 +2,7 @@ # which is based on the PCRE library import - regexprs, io + regexprs if "Username" =~ "[A-Za-z]+": echo("Yes!") diff --git a/tests/treguse.nim b/tests/treguse.nim index 054866037..dc805fc70 100644 --- a/tests/treguse.nim +++ b/tests/treguse.nim @@ -1,9 +1,6 @@ # Test the register usage of the virtual machine and # the blocks in var statements -import - io - proc main(a, b: int) = var x = 0 write(stdout, x) diff --git a/tests/trepr.nim b/tests/trepr.nim index 9dd1c2b82..ec3731332 100644 --- a/tests/trepr.nim +++ b/tests/trepr.nim @@ -1,10 +1,7 @@ # test the new "repr" built-in proc -import - io - type - TPoint = record + TPoint {.final.} = object x, y, z: int s: array [0..1, string] diff --git a/tests/tseqcon.nim b/tests/tseqcon.nim index dbeb6a4ef..f5d0346ae 100644 --- a/tests/tseqcon.nim +++ b/tests/tseqcon.nim @@ -1,10 +1,7 @@ # Test the &= operator for sequences and strings -import - io - type - TRec = record + TRec {.final.} = object x, y: int s: string seq: seq[string] diff --git a/tests/tsizeof.nim b/tests/tsizeof.nim index cd29643a8..f7b70dd4d 100644 --- a/tests/tsizeof.nim +++ b/tests/tsizeof.nim @@ -1,10 +1,7 @@ # Test the sizeof proc -import - io - type - TMyRecord = record + TMyRecord {.final.} = object x, y: int b: bool r: float diff --git a/tests/tstrdesc.nim b/tests/tstrdesc.nim index 58e8b7842..d25579ee2 100644 --- a/tests/tstrdesc.nim +++ b/tests/tstrdesc.nim @@ -4,12 +4,11 @@ var x = [0, 1, 2] type - TStringDesc = record + TStringDesc {.final.} = object len, space: int # len and space without counting the terminating zero data: array [0..0, char] # for the '\0' character var - emptyString {.export: "emptyString".}: TStringDesc = ( - len: 0, space: 0, data: ['\0'] - ) + emptyString {.export: "emptyString".}: TStringDesc + diff --git a/tests/tstrdist.nim b/tests/tstrdist.nim index 99d685eab..482e363ef 100644 --- a/tests/tstrdist.nim +++ b/tests/tstrdist.nim @@ -1,8 +1,5 @@ # compute the edit distance between two strings -import - io - proc editDistance(a, b: string): int = var c: seq[int] = [] var diff --git a/tests/tstrutil.nim b/tests/tstrutil.nim index 9ed2ace3a..985656f2f 100644 --- a/tests/tstrutil.nim +++ b/tests/tstrutil.nim @@ -1,7 +1,7 @@ # test the new strutils module import - strutils, io + strutils proc testStrip() = write(stdout, strip(" ha ")) diff --git a/tests/tvarious.nim b/tests/tvarious.nim index 1c15a87ba..52dd46184 100644 --- a/tests/tvarious.nim +++ b/tests/tvarious.nim @@ -1,16 +1,16 @@ # Test various aspects import - mvarious, io + mvarious type PA = ref TA PB = ref TB - TB = record + TB = object a: PA - TA = record + TA = object b: TB x: int diff --git a/tests/tvarnums.nim b/tests/tvarnums.nim index f77478081..f57eeef41 100644 --- a/tests/tvarnums.nim +++ b/tests/tvarnums.nim @@ -1,7 +1,7 @@ # Test variable length binary integers import - io, strutils + strutils type TBuffer = array [0..10, int8] diff --git a/tests/twalker.nim b/tests/twalker.nim index acdca9362..ba89ee7c6 100644 --- a/tests/twalker.nim +++ b/tests/twalker.nim @@ -1,7 +1,7 @@ # iterate over all files with a given filter: import - io, os, times + os, times proc main(filter: string) = for filename in walkFiles(filter): @@ -10,4 +10,4 @@ proc main(filter: string) = for key, val in iterOverEnvironment(): writeln(stdout, key & '=' & val) -main("*.mor") +main("*.nim") diff --git a/tests/walker.bpf b/tests/walker.bpf deleted file mode 100644 index 819d6b63a..000000000 --- a/tests/walker.bpf +++ /dev/null @@ -1,13 +0,0 @@ -USEUNIT("twalker.c"); -USEUNIT("..\lib\morlib.c"); -USEUNIT("..\lib\os.c"); -USEUNIT("..\lib\refcgc.c"); -USEUNIT("..\lib\strutils.c"); -USEUNIT("..\lib\time.c"); -USEUNIT("..\lib\io.c"); -USEUNIT("..\lib\morbase.c"); -//--------------------------------------------------------------------------- -This file is used by the project manager only and should be treated like the project file - - -main \ No newline at end of file diff --git a/tests/walker.bpr b/tests/walker.bpr deleted file mode 100644 index 6b702f59f..000000000 --- a/tests/walker.bpr +++ /dev/null @@ -1,102 +0,0 @@ -<?xml version='1.0' encoding='utf-8' ?> -<!-- C++Builder XML Project --> -<PROJECT> - <MACROS> - <VERSION value="BCB.05.03"/> - <PROJECT value="walker.exe"/> - <OBJFILES value="twalker.obj ..\lib\morlib.obj ..\lib\os.obj ..\lib\refcgc.obj - ..\lib\strutils.obj ..\lib\time.obj ..\lib\io.obj ..\lib\morbase.obj"/> - <RESFILES value=""/> - <DEFFILE value=""/> - <RESDEPEN value="$(RESFILES)"/> - <LIBFILES value=""/> - <LIBRARIES value=""/> - <SPARELIBS value=""/> - <PACKAGES value="Vcl50.bpi Vclx50.bpi bcbsmp50.bpi dclocx50.bpi bcb2kaxserver50.bpi"/> - <PATHCPP value=".;..\lib"/> - <PATHPAS value=".;"/> - <PATHRC value=".;"/> - <PATHASM value=".;"/> - <DEBUGLIBPATH value="$(BCB)\lib\debug"/> - <RELEASELIBPATH value="$(BCB)\lib\release"/> - <LINKER value="tlink32"/> - <USERDEFINES value="_DEBUG"/> - <SYSDEFINES value="NO_STRICT;_NO_VCL;_RTLDLL;USEPACKAGES"/> - <MAINSOURCE value="walker.bpf"/> - <INCLUDEPATH value="..\lib;$(BCB)\include;$(BCB)\include\vcl"/> - <LIBPATH value="..\lib;$(BCB)\lib\obj;$(BCB)\lib"/> - <WARNINGS value="-w-par"/> - </MACROS> - <OPTIONS> - <CFLAG1 value="-Od -H=$(BCB)\lib\vcl50.csm -Hc -Vx -Ve -X- -r- -a8 -b- -k -y -v -vi- -tWC - -tWM- -c"/> - <PFLAGS value="-$YD -$W -$O- -v -JPHNE -M"/> - <RFLAGS value=""/> - <AFLAGS value="/mx /w2 /zd"/> - <LFLAGS value="-D"" -ap -Tpe -x -Gn -v"/> - </OPTIONS> - <LINKER> - <ALLOBJ value="c0x32.obj $(PACKAGES) $(OBJFILES)"/> - <ALLRES value="$(RESFILES)"/> - <ALLLIB value="$(LIBFILES) $(LIBRARIES) import32.lib cw32i.lib"/> - </LINKER> - <IDEOPTIONS> -[Version Info] -IncludeVerInfo=0 -AutoIncBuild=0 -MajorVer=1 -MinorVer=0 -Release=0 -Build=0 -Debug=0 -PreRelease=0 -Special=0 -Private=0 -DLL=0 -Locale=1031 -CodePage=1252 - -[Version Info Keys] -CompanyName= -FileDescription= -FileVersion=1.0.0.0 -InternalName= -LegalCopyright= -LegalTrademarks= -OriginalFilename= -ProductName= -ProductVersion=1.0.0.0 -Comments= - -[HistoryLists\hlIncludePath] -Count=2 -Item0=..\lib;$(BCB)\include;$(BCB)\include\vcl;C:\Eigenes\morpork\lib -Item1=..\lib;$(BCB)\include;$(BCB)\include\vcl - -[HistoryLists\hlLibraryPath] -Count=1 -Item0=..\lib;$(BCB)\lib\obj;$(BCB)\lib - -[HistoryLists\hlDebugSourcePath] -Count=1 -Item0=$(BCB)\source\vcl - -[HistoryLists\hlConditionals] -Count=1 -Item0=_DEBUG - -[Debugging] -DebugSourceDirs=$(BCB)\source\vcl - -[Parameters] -RunParams= -HostApplication= -RemoteHost= -RemotePath= -RemoteDebug=0 - -[Compiler] -ShowInfoMsgs=0 -LinkDebugVcl=0 - </IDEOPTIONS> -</PROJECT> \ No newline at end of file |