refactor: consolidate per-test subdirectories into flat test/api structure with merged returns and value files
This commit is contained in:
@@ -1,3 +0,0 @@
|
||||
#include "wren.h"
|
||||
|
||||
WrenForeignMethodFn getValueBindForeign(const char* signature);
|
||||
+5
-11
@@ -5,10 +5,8 @@
|
||||
#include "vm.h"
|
||||
#include "wren.h"
|
||||
|
||||
#include "get_value/get_value.h"
|
||||
#include "return_bool/return_bool.h"
|
||||
#include "return_double/return_double.h"
|
||||
#include "return_null/return_null.h"
|
||||
#include "value.h"
|
||||
#include "returns.h"
|
||||
|
||||
#define REGISTER_TEST(name, camelCase) \
|
||||
if (strcmp(testName, #name) == 0) return camelCase##BindForeign(fullName)
|
||||
@@ -31,10 +29,8 @@ static WrenForeignMethodFn bindForeign(
|
||||
strcat(fullName, ".");
|
||||
strcat(fullName, signature);
|
||||
|
||||
REGISTER_TEST(get_value, getValue);
|
||||
REGISTER_TEST(return_bool, returnBool);
|
||||
REGISTER_TEST(return_double, returnDouble);
|
||||
REGISTER_TEST(return_null, returnNull);
|
||||
REGISTER_TEST(returns, returns);
|
||||
REGISTER_TEST(value, value);
|
||||
|
||||
fprintf(stderr,
|
||||
"Unknown foreign method '%s' for test '%s'\n", fullName, testName);
|
||||
@@ -52,12 +48,10 @@ int main(int argc, const char* argv[])
|
||||
|
||||
testName = argv[1];
|
||||
|
||||
// The test script is at "test/api/<test>/<test>.wren".
|
||||
// The test script is at "test/api/<test>.wren".
|
||||
char testPath[256];
|
||||
strcpy(testPath, "test/api/");
|
||||
strcat(testPath, testName);
|
||||
strcat(testPath, "/");
|
||||
strcat(testPath, testName);
|
||||
strcat(testPath, ".wren");
|
||||
|
||||
runFile(bindForeign, testPath);
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
#include <string.h>
|
||||
|
||||
#include "return_bool.h"
|
||||
|
||||
static void returnTrue(WrenVM* vm)
|
||||
{
|
||||
wrenReturnBool(vm, true);
|
||||
}
|
||||
|
||||
static void returnFalse(WrenVM* vm)
|
||||
{
|
||||
wrenReturnBool(vm, false);
|
||||
}
|
||||
|
||||
WrenForeignMethodFn returnBoolBindForeign(const char* signature)
|
||||
{
|
||||
if (strcmp(signature, "static Api.returnTrue") == 0) return returnTrue;
|
||||
if (strcmp(signature, "static Api.returnFalse") == 0) return returnFalse;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
#include "wren.h"
|
||||
|
||||
WrenForeignMethodFn returnBoolBindForeign(const char* signature);
|
||||
@@ -1,7 +0,0 @@
|
||||
class Api {
|
||||
foreign static returnTrue
|
||||
foreign static returnFalse
|
||||
}
|
||||
|
||||
IO.print(Api.returnTrue) // expect: true
|
||||
IO.print(Api.returnFalse) // expect: false
|
||||
@@ -1,21 +0,0 @@
|
||||
#include <string.h>
|
||||
|
||||
#include "return_double.h"
|
||||
|
||||
static void returnInt(WrenVM* vm)
|
||||
{
|
||||
wrenReturnDouble(vm, 123456);
|
||||
}
|
||||
|
||||
static void returnFloat(WrenVM* vm)
|
||||
{
|
||||
wrenReturnDouble(vm, 123.456);
|
||||
}
|
||||
|
||||
WrenForeignMethodFn returnDoubleBindForeign(const char* signature)
|
||||
{
|
||||
if (strcmp(signature, "static Api.returnInt") == 0) return returnInt;
|
||||
if (strcmp(signature, "static Api.returnFloat") == 0) return returnFloat;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
#include "wren.h"
|
||||
|
||||
WrenForeignMethodFn returnDoubleBindForeign(const char* signature);
|
||||
@@ -1,7 +0,0 @@
|
||||
class Api {
|
||||
foreign static returnInt
|
||||
foreign static returnFloat
|
||||
}
|
||||
|
||||
IO.print(Api.returnInt) // expect: 123456
|
||||
IO.print(Api.returnFloat) // expect: 123.456
|
||||
@@ -1,15 +0,0 @@
|
||||
#include <string.h>
|
||||
|
||||
#include "return_null.h"
|
||||
|
||||
static void implicitNull(WrenVM* vm)
|
||||
{
|
||||
// Do nothing.
|
||||
}
|
||||
|
||||
WrenForeignMethodFn returnNullBindForeign(const char* signature)
|
||||
{
|
||||
if (strcmp(signature, "static Api.implicitNull") == 0) return implicitNull;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
#include "wren.h"
|
||||
|
||||
WrenForeignMethodFn returnNullBindForeign(const char* signature);
|
||||
@@ -1,5 +0,0 @@
|
||||
class Api {
|
||||
foreign static implicitNull
|
||||
}
|
||||
|
||||
IO.print(Api.implicitNull == null) // expect: true
|
||||
@@ -0,0 +1,39 @@
|
||||
#include <string.h>
|
||||
|
||||
#include "returns.h"
|
||||
|
||||
static void implicitNull(WrenVM* vm)
|
||||
{
|
||||
// Do nothing.
|
||||
}
|
||||
|
||||
static void returnInt(WrenVM* vm)
|
||||
{
|
||||
wrenReturnDouble(vm, 123456);
|
||||
}
|
||||
|
||||
static void returnFloat(WrenVM* vm)
|
||||
{
|
||||
wrenReturnDouble(vm, 123.456);
|
||||
}
|
||||
|
||||
static void returnTrue(WrenVM* vm)
|
||||
{
|
||||
wrenReturnBool(vm, true);
|
||||
}
|
||||
|
||||
static void returnFalse(WrenVM* vm)
|
||||
{
|
||||
wrenReturnBool(vm, false);
|
||||
}
|
||||
|
||||
WrenForeignMethodFn returnsBindForeign(const char* signature)
|
||||
{
|
||||
if (strcmp(signature, "static Api.implicitNull") == 0) return implicitNull;
|
||||
if (strcmp(signature, "static Api.returnInt") == 0) return returnInt;
|
||||
if (strcmp(signature, "static Api.returnFloat") == 0) return returnFloat;
|
||||
if (strcmp(signature, "static Api.returnTrue") == 0) return returnTrue;
|
||||
if (strcmp(signature, "static Api.returnFalse") == 0) return returnFalse;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
#include "wren.h"
|
||||
|
||||
WrenForeignMethodFn returnsBindForeign(const char* signature);
|
||||
@@ -0,0 +1,17 @@
|
||||
class Api {
|
||||
foreign static implicitNull
|
||||
|
||||
foreign static returnInt
|
||||
foreign static returnFloat
|
||||
|
||||
foreign static returnTrue
|
||||
foreign static returnFalse
|
||||
}
|
||||
|
||||
IO.print(Api.implicitNull == null) // expect: true
|
||||
|
||||
IO.print(Api.returnInt) // expect: 123456
|
||||
IO.print(Api.returnFloat) // expect: 123.456
|
||||
|
||||
IO.print(Api.returnTrue) // expect: true
|
||||
IO.print(Api.returnFalse) // expect: false
|
||||
@@ -1,6 +1,6 @@
|
||||
#include <string.h>
|
||||
|
||||
#include "get_value.h"
|
||||
#include "value.h"
|
||||
|
||||
static WrenValue* value;
|
||||
|
||||
@@ -15,7 +15,7 @@ static void getValue(WrenVM* vm)
|
||||
wrenReleaseValue(vm, value);
|
||||
}
|
||||
|
||||
WrenForeignMethodFn getValueBindForeign(const char* signature)
|
||||
WrenForeignMethodFn valueBindForeign(const char* signature)
|
||||
{
|
||||
if (strcmp(signature, "static Api.value=(_)") == 0) return setValue;
|
||||
if (strcmp(signature, "static Api.value") == 0) return getValue;
|
||||
@@ -0,0 +1,3 @@
|
||||
#include "wren.h"
|
||||
|
||||
WrenForeignMethodFn valueBindForeign(const char* signature);
|
||||
Reference in New Issue
Block a user