Skip to content

Commit

Permalink
ReaScript function export: added crappy test scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeff0S committed Apr 1, 2015
1 parent 221f175 commit 6da4dc9
Show file tree
Hide file tree
Showing 2 changed files with 441 additions and 0 deletions.
204 changes: 204 additions & 0 deletions reascript_test.eel
Original file line number Diff line number Diff line change
@@ -0,0 +1,204 @@
ShowConsoleMsg("");

tr=GetTrack(0,0);
extension_api("SNM_AddTCPFXParm",tr,0,0);
extension_api("SNM_AddTCPFXParm",tr,0,1);
extension_api("SNM_AddTCPFXParm",tr,0,2);

// EEL: bool extension_api("SNM_SetProjectMarker", ReaProject proj, int num, bool isrgn, pos, rgnend, "name", int color)
// Lua: boolean reaper.SNM_SetProjectMarker(ReaProject proj, integer num, boolean isrgn, number pos, number rgnend, string name, integer color)
extension_api("SNM_SetProjectMarker", 0.0, 1.0, 1.0, 0.0, 2.0, "test NULL proj", 0);


// EEL: bool extension_api("SNM_GetFastString", #retval, WDL_FastString str)
// Lua: string reaper.SNM_GetFastString(WDL_FastString str)
ShowConsoleMsg("SNM_CreateFastString+SNM_GetFastString: ");
w = extension_api("SNM_CreateFastString","ok\n");
extension_api("SNM_GetFastString",aa,w);
ShowConsoleMsg(aa);


// { APIFUNC(SNM_test1), "int", "int*", "aOut", "", },
// EEL: int extension_api("SNM_test1", int &aOut)
// Lua: integer retval, number aOut reaper.SNM_test1()
ShowConsoleMsg("SNM_test1\n");
test1r=0;
test1p=12;
test1r = extension_api("SNM_test1",test1p);
(test1r == 666 ) ? (
ShowConsoleMsg("ok\n");
) : (
ShowConsoleMsg("KO !\n");
);
(test1p == 2 ) ? (
ShowConsoleMsg("ok\n");
) : (
ShowConsoleMsg("KO !\n");
);


// { APIFUNC(SNM_test2), "double", "double*", "aOut", "", },
// EEL: double extension_api("SNM_test2", &aOut)
// Lua: number retval, number aOut reaper.SNM_test2()
ShowConsoleMsg("SNM_test2\n");
test2r=0.0;
test2p=0.0;
test2r = extension_api("SNM_test2",test2p);
(test2r == 666.777 ) ? (
ShowConsoleMsg("ok\n");
) : (
ShowConsoleMsg("KO !\n");
);
(test2p == 1.23456789 ) ? (
ShowConsoleMsg("ok\n");
) : (
ShowConsoleMsg("KO !\n");
);


// { APIFUNC(SNM_test3), "bool", "int*,double*,bool*", "aOut,bOut,cOut", "", },
// EEL: bool extension_api("SNM_test3", int &aOut, &bOut, bool &cOut)
// Lua: boolean retval, number aOut, number bOut, boolean cOut reaper.SNM_test3()
ShowConsoleMsg("SNM_test3\n");
test3=0; testa=333; testb=333.444; testc=1.0;
test3 = extension_api("SNM_test3",testa,testb,testc);
(test3 == 1 ) ? (
ShowConsoleMsg("ok\n");
) : (
ShowConsoleMsg("KO !\n");
);
(testa == 666 ) ? (
ShowConsoleMsg("ok\n");
) : (
ShowConsoleMsg("KO !\n");
);
(testb == 666.888 ) ? (
ShowConsoleMsg("ok\n");
) : (
ShowConsoleMsg("KO !\n");
);
(testc == 0.0 ) ? (
ShowConsoleMsg("ok\n");
) : (
ShowConsoleMsg("KO !\n");
);


// { APIFUNC(SNM_test4), "void", "double", "a", "", },
// EEL: extension_api("SNM_test4", a)
// Lua: reaper.SNM_test4(number a)
ShowConsoleMsg("SNM_test4\n");
test4=123.456789;
extension_api("SNM_test4",test4);


// { APIFUNC(SNM_test5), "void", "const char*", "a", "", },
// EEL: extension_api("SNM_test5", "a")
// Lua: reaper.SNM_test5(string a)
ShowConsoleMsg("SNM_test5\n");
test5="SNM_test5";
extension_api("SNM_test5",test5);


// { APIFUNC(SNM_test6), "const char*", "char*", "a", "", }, // not an "Out" parm
// EEL: bool extension_api("SNM_test6", #retval, #a)
// Lua: string retval, string a SNM_test6(string a)
ShowConsoleMsg("SNM_test6\n");
#test6p="SNM_test6";
#test6r="SNM_test6";
extension_api("SNM_test6",#test6r,#test6p);
ShowConsoleMsg(#test6p);
(!strcmp(#test6p,"SNM_test6 new parm val") ) ? (
ShowConsoleMsg(": ok\n");
) : (
ShowConsoleMsg(": KO !\n");
);
ShowConsoleMsg(#test6r);
(!strcmp(#test6r,"SNM_test6 return val") ) ? (
ShowConsoleMsg(": ok\n");
) : (
ShowConsoleMsg(": KO !\n");
);

// == test3 somehow but opt params + return double on top
// { APIFUNC(SNM_test7), "double", "int,int*,double*,bool*", "i,aOut,bOutOptional,cOutOptional", "", },
// EEL: double extension_api("SNM_test7", int i, int &aOut, optional &bOutOptional, optional bool &cOutOptional)
// Lua: number retval, number aOut, optional number bOutOptional, optional boolean cOutOptional SNM_test7(integer i)
ShowConsoleMsg("SNM_test7 with all params (more than doc)\n");
test7=0.0; testa=333; testb=333.444; testc=1.0;
#ble="lkjlkj";
#bla="cs";
test7 = extension_api("SNM_test7",7,testa,testb,testc,#ble,#bla);
(test7 == 666.777 ) ? (
ShowConsoleMsg("ok\n");
) : (
ShowConsoleMsg("KO !\n");
);
(testa == 666 ) ? (
ShowConsoleMsg("ok\n");
) : (
ShowConsoleMsg("KO !\n");
);
(testb == 666.888 ) ? (
ShowConsoleMsg("ok\n");
) : (
ShowConsoleMsg("KO !\n");
);
(testc == 0.0 ) ? (
ShowConsoleMsg("ok\n");
) : (
ShowConsoleMsg("KO !\n");
);
(!strcmp(#ble,"SNM_test7 new parm val") ) ? (
ShowConsoleMsg("ok\n");
) : (
ShowConsoleMsg("KO !\n");
);

ShowConsoleMsg("SNM_test7 with min params (like the doc)\n");
testa=12;
test72r = extension_api("SNM_test7",7,testa);
(test72r == 666.777 ) ? (
ShowConsoleMsg("ok\n");
) : (
ShowConsoleMsg("KO !\n");
);
(testa == 24 ) ? (
ShowConsoleMsg("ok\n");
) : (
ShowConsoleMsg("KO !\n");
);


ShowConsoleMsg("SNM_test8\n");
#buf1="buf1";
#buf2="buf22";
#buf3="buf33";
test8p=321.0;
extension_api("SNM_test8",#test8r,#buf1,#buf2,666,#buf3,test8p);
(!strcmp(#test8r,"SNM_test8") ) ? (
ShowConsoleMsg("ok\n");
) : (
ShowConsoleMsg("KO !\n");
);
(!strcmp(#buf1,"SNM_test8 new parm val for buf1") ) ? (
ShowConsoleMsg("ok\n");
) : (
ShowConsoleMsg("KO !\n");
);
(!strcmp(#buf2,"buf22") ) ? ( // this test is a bit silly (buf2 is const char*)
ShowConsoleMsg("ok\n");
) : (
ShowConsoleMsg("KO !\n");
);
(!strcmp(#buf3,"SNM_test8 new parm val for buf3") ) ? (
ShowConsoleMsg("ok\n");
) : (
ShowConsoleMsg("KO !\n");
);
(test8p==123456789.0) ? (
ShowConsoleMsg("ok\n");
) : (
ShowConsoleMsg("KO !\n");
);

Loading

0 comments on commit 6da4dc9

Please sign in to comment.