ADD: test script.
parent
ee1b52cae1
commit
0aa9ebd952
|
@ -0,0 +1,43 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
TOTAL=0
|
||||
SUCCESS=0
|
||||
|
||||
for file in `find -name "*.zn"`
|
||||
do
|
||||
NAME=$(basename $file | cut -d'.' -f1)
|
||||
MSG=$(zarn "$file" 2>&1 > /dev/null)
|
||||
|
||||
STATUS=$?
|
||||
|
||||
echo -en "\e[34m$NAME ... \e[0m"
|
||||
if [ $STATUS -eq 0 ]
|
||||
then
|
||||
echo -e "\e[32mok\e[0m"
|
||||
SUCCESS=$(($SUCCESS + 1))
|
||||
else
|
||||
echo -e "\e[31mko\e[0m"
|
||||
echo "$MSG"
|
||||
fi
|
||||
|
||||
TOTAL=$((TOTAL + 1))
|
||||
done
|
||||
|
||||
FAILURE=$(($TOTAL - $SUCCESS))
|
||||
|
||||
if [ $SUCCESS -eq $TOTAL ]
|
||||
then
|
||||
echo -e "\e[32m======== All tests passed ========\e[0m"
|
||||
else
|
||||
echo -e "\e[31m======== $FAILURE tests failed ========\e[0m"
|
||||
fi
|
||||
|
||||
echo -e "\e[0mok:\t$SUCCESS\e[0m"
|
||||
echo -e "\e[0mko:\t$FAILURE\e[0m"
|
||||
|
||||
if [ $SUCCESS -eq $TOTAL ]
|
||||
then
|
||||
echo -e "\e[32mTOTAL:\t$TOTAL\e[0m"
|
||||
else
|
||||
echo -e "\e[31mTOTAL:\t$TOTAL\e[0m"
|
||||
fi
|
|
@ -1,9 +1,9 @@
|
|||
#include "macro.hpp"
|
||||
|
||||
std::shared_ptr<Constant> assert_fail(Node const& node,
|
||||
void assert_fail(Node const& node,
|
||||
Compiler& compiler,
|
||||
Program& program,
|
||||
SymTable& sym)
|
||||
SymTable&)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -18,5 +18,7 @@ std::shared_ptr<Constant> assert_fail(Node const& node,
|
|||
{
|
||||
}
|
||||
|
||||
return std::make_shared<Constant>(TYPE_NIL, node.loc(), 0);
|
||||
size_t addr = program.add_constant(std::make_shared<Constant>
|
||||
(TYPE_NIL, node.loc(), 0));
|
||||
program.append(OPCODE_LOAD_CONST, addr);
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
#include "common.hpp"
|
||||
|
||||
std::shared_ptr<Constant> assert_fail(Node const& node,
|
||||
void assert_fail(Node const& node,
|
||||
Compiler& compiler,
|
||||
Program& program,
|
||||
SymTable& sym);
|
||||
|
|
|
@ -57,10 +57,8 @@ namespace zn
|
|||
{
|
||||
if (macro->name() == ident)
|
||||
{
|
||||
auto res = macro->execute(node, *this,
|
||||
macro->execute(node, *this,
|
||||
program, m_sym);
|
||||
size_t addr = program.add_constant(res);
|
||||
program.append(OPCODE_LOAD_CONST, addr);
|
||||
found_macro = true;
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -13,12 +13,11 @@ namespace zn
|
|||
{
|
||||
}
|
||||
|
||||
std::shared_ptr<Constant>
|
||||
NativeMacro::execute(Node const& node,
|
||||
void NativeMacro::execute(Node const& node,
|
||||
Compiler& compiler,
|
||||
Program& program,
|
||||
SymTable& sym)
|
||||
{
|
||||
return m_macro(node, compiler, program, sym);
|
||||
m_macro(node, compiler, program, sym);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
namespace zn
|
||||
{
|
||||
using native_macro_t = std::function<std::shared_ptr<Constant>
|
||||
using native_macro_t = std::function<void
|
||||
(Node const&,
|
||||
Compiler&,
|
||||
Program&,
|
||||
|
@ -23,8 +23,8 @@ namespace zn
|
|||
|
||||
std::string name() const { return m_name; }
|
||||
|
||||
std::shared_ptr<Constant>
|
||||
execute(Node const& node,
|
||||
|
||||
void execute(Node const& node,
|
||||
Compiler& compiler,
|
||||
Program& program,
|
||||
SymTable& sym);
|
||||
|
|
|
@ -13,10 +13,10 @@ namespace zn
|
|||
|
||||
/*virtual*/ Zarn::~Zarn()
|
||||
{
|
||||
for (void* handler: m_handlers)
|
||||
{
|
||||
// dlclose(handler);
|
||||
}
|
||||
//for (void* handler: m_handlers)
|
||||
// {
|
||||
// // dlclose(handler);
|
||||
// }
|
||||
|
||||
m_handlers.clear();
|
||||
}
|
||||
|
|
Reference in New Issue