view tests/mini/arrays15.d @ 650:aa6a0b7968f7

Added test case for bug #100 Removed dubious check for not emitting static private global in other modules without access. This should be handled properly somewhere else, it's causing unresolved global errors for stuff that should work (in MiniD)
author Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
date Sun, 05 Oct 2008 17:28:15 +0200
parents 1bb99290e03a
children
line wrap: on
line source

module arrays15;

extern(C) int printf(char*, ...);

void integer()
{
    auto arr = new int[16];
    arr[1] = 42;
    arr[6] = 555;
    print_int(arr);
    delete arr;
}

void floating()
{
    auto arr = new float[6];
    arr[1] = 3.14159265;
    arr[3] = 1.61803399;
    print_float(arr);
    delete arr;
}

void print_int(int[] arr)
{
    printf("arr[%lu] = [", arr.length);
    for (auto i=0; i<arr.length; i++)
        printf("%d,", arr[i]);
    printf("\b]\n");
}

void print_float(float[] arr)
{
    printf("arr[%lu] = [", arr.length);
    for (auto i=0; i<arr.length; i++)
        printf("%f,", arr[i]);
    printf("\b]\n");
}

void main()
{
    integer();
    floating();
}