From 7930b048b8ccf35b081175ed80c4832281d82a67 Mon Sep 17 00:00:00 2001 From: "Samuel D. Crow" Date: Thu, 4 Aug 2022 21:18:26 -0500 Subject: [PATCH] wrote on n sub unit test and made necessary fixes --- runtime/Makefile | 6 ++--- tester.cpp | 53 +++++++++++++++++++++++++++++++++++++++++++ yab2cpp.h | 4 +++- yabCodeStructures.cpp | 47 ++++++++++++++++++-------------------- yabFunctions.cpp | 14 ++++++------ 5 files changed, 88 insertions(+), 36 deletions(-) diff --git a/runtime/Makefile b/runtime/Makefile index 0892928..84b048c 100644 --- a/runtime/Makefile +++ b/runtime/Makefile @@ -1,9 +1,9 @@ CC := g++ CFLAGS := -Wall CFLAGS += -std=c++11 -#CFLAGS += -fno-rtti -#CFLAGS += -fno-exceptions -#CFLAGS += -Os +CFLAGS += -fno-rtti +CFLAGS += -fno-exceptions +CFLAGS += -Os LFLAGS := .PHONY: all diff --git a/tester.cpp b/tester.cpp index dbb5f34..974a0b4 100644 --- a/tester.cpp +++ b/tester.cpp @@ -410,6 +410,58 @@ void testForLoop() logger("testForLoop cleared"); } +void testOnNCall() +{ + logger("testOnNCall entered"); + string s1 = string("func1"); + fn *f1=fn::declare(s1, T_UNKNOWNFUNC); + print=new printSegment(new expression(new constOp(string("one"), T_STRING))); + print->generate(); + delete print; + f1->close(); + logger("func1 declared"); + string s2=string("func2"); + fn *f2=fn::declare(s2, T_UNKNOWNFUNC); + print=new printSegment(new expression(new constOp(string("two"), T_STRING))); + print->generate(); + delete print; + f2->close(); + logger("func2 declared"); + string s3=string("func3"); + fn *f3=fn::declare(s3, T_UNKNOWNFUNC); + print=new printSegment(new expression(new constOp(string("three"), T_STRING))); + print->generate(); + delete print; + f3->close(); + logger("func3 declared"); + string s=string("countdown"); + variableType *q=variableType::getOrCreateVar(s, T_INTVAR); + logger("countdown var declared"); + forLoop *f=new forLoop(q, + new expression(new constOp("3",T_INT)), + new expression(new constOp("0",T_INT)), + new expression(new constOp("-1",T_INT)) + ); + logger("forloop declared"); + list