mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-18 21:30:38 +01:00
[Quiz] Support C++ cases
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
#include <quiz.h>
|
||||
#include <kandinsky.h>
|
||||
|
||||
TEST(setpixel) {
|
||||
QUIZ_CASE(setpixel) {
|
||||
2+2;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include <quiz.h>
|
||||
#include <poincare.h>
|
||||
|
||||
TEST(integer) {
|
||||
QUIZ_CASE(integer) {
|
||||
1+1;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
SFLAGS += -Iquiz/include
|
||||
objs += $(addprefix quiz/src/, runner.o symbols.o)
|
||||
|
||||
symbols_file = $(addprefix quiz/src/, symbols.c)
|
||||
products += $(symbols_file)
|
||||
@@ -9,4 +10,6 @@ $(symbols_file): $(tests)
|
||||
|
||||
test_objs = $(subst .c,.o, $(subst .cpp,.o,$(tests)))
|
||||
|
||||
test.elf: quiz/src/symbols.o quiz/src/runner.o $(test_objs)
|
||||
test.elf: $(objs) $(test_objs)
|
||||
@echo "LD $@"
|
||||
@$(LD) $(LDFLAGS) $(objs) $(test_objs) -o $@
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
#ifndef QUIZ_H
|
||||
#define QUIZ_H
|
||||
|
||||
#define TEST(foo) void test_##foo()
|
||||
#ifdef __cplusplus
|
||||
#define QUIZ_CASE(name) extern "C" { void quiz_case_##name();}; void quiz_case_##name()
|
||||
#else
|
||||
#define QUIZ_CASE(name) void quiz_case_##name()
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -6,7 +6,7 @@ BEGIN {
|
||||
|
||||
#FIXME: Is there a way to capture subexpression in awk? The following gsub is
|
||||
# kind of ugly
|
||||
/TEST\(([a-z0-9_]+)\)/ { gsub(/(TEST\()|(\))/, "", $1); tests = tests "," $1 }
|
||||
/QUIZ_CASE\(([a-z0-9_]+)\)/ { gsub(/(QUIZ_CASE\()|(\))/, "", $1); tests = tests ",quiz_case_" $1 }
|
||||
|
||||
END {
|
||||
a = tests;
|
||||
|
||||
Reference in New Issue
Block a user