Skip to content

Commit 5dd8f04

Browse files
committed
Restructure test-c-codegen/
1 parent e2890a1 commit 5dd8f04

File tree

11 files changed

+34
-24
lines changed

11 files changed

+34
-24
lines changed

test-c-codegen/.gitignore

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1 @@
1-
main.mz
2-
mazeppa.h
3-
sds*
41
main
5-
panic

test-c-codegen/panic.c renamed to test-c-codegen/execution-panic/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#include "mazeppa.h"
1+
#include "../mazeppa.h"
22

33
int main(void) {
44
(void)MZ_OP2(MZ_INT(I, 32, 1), div, MZ_INT(I, 32, 0));
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
$CC main.c ../sds.c -lgc -o main $COMMON_OPTIONS
6+
if ! ./main 2>&1 >/dev/null \
7+
| grep -q 'Execution panic: "out of range"'; then
8+
echo "Expected a panic."
9+
fi

test-c-codegen/mazeppa.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../c/mazeppa.h

test-c-codegen/sds.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../c/deps/sds.c

test-c-codegen/sds.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../c/deps/sds.h

test-c-codegen/sdsalloc.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../c/deps/sdsalloc.h

test-c-codegen/main.c renamed to test-c-codegen/self-interpreter/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#include "mazeppa.h"
1+
#include "../mazeppa.h"
22

33
mz_Value run(void);
44

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../examples/self-interpreter/main.mz
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/bash
2+
3+
# The fact that the self-interpreter uses almost all the language features makes
4+
# it a good example for testing.
5+
6+
set -e
7+
8+
cat program.mz \
9+
| ../../scripts/mazeppa.sh translate --language C --entry run \
10+
| $CC -c -o program.o $COMMON_OPTIONS -xc -I.. -
11+
$CC main.c program.o ../sds.c -lgc -o main $COMMON_OPTIONS
12+
./main

test-c-codegen/test.sh

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,28 +9,16 @@ fi
99
common_options="-Wall -Werror -Wno-unused-variable -Wno-infinite-recursion"
1010
common_options="$common_options -std=gnu11"
1111

12-
cp -r ../c/deps/sds* .
13-
1412
# All the examples must at least compile with no errors.
1513
for example in ../examples/*/; do
1614
cat "${example}main.mz" \
1715
| ../scripts/mazeppa.sh translate --language C --entry run \
18-
--dump-header-to . \
1916
| $CC -c -o /dev/null $common_options -xc -
2017
done
2118

22-
# Compile and execute the self-interpreter example (convenient for testing).
23-
cp ../examples/self-interpreter/main.mz main.mz
24-
cat main.mz \
25-
| ../scripts/mazeppa.sh translate --language C --entry run \
26-
--dump-header-to . \
27-
| $CC -c -o program.o $common_options -xc -
28-
$CC main.c program.o sds.c -lgc -o main $common_options
29-
./main
30-
31-
# Make sure that run-time panics work as expected.
32-
$CC panic.c sds.c -lgc -o panic $common_options
33-
if ! ./panic 2>&1 >/dev/null \
34-
| grep -q 'Execution panic: "out of range"'; then
35-
echo "Expected a panic."
36-
fi
19+
for test_dir in */; do
20+
echo "Testing '$test_dir'..."
21+
cd $test_dir
22+
COMMON_OPTIONS=$common_options ./test.sh
23+
cd ..
24+
done

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy