Browse Source

Add tests directory.

tags/v1.1.0
Andrew Belt 5 years ago
parent
commit
1b4339ddbf
6 changed files with 13 additions and 2 deletions
  1. +2
    -2
      README.md
  2. +3
    -0
      src/DuktapeEngine.cpp
  3. +2
    -0
      src/Prototype.cpp
  4. +4
    -0
      tests/process_error.js
  5. +1
    -0
      tests/run_error.js
  6. +1
    -0
      tests/syntax_error.js

+ 2
- 2
README.md View File

@@ -23,7 +23,7 @@ display(message)
For CV generators and processors, 256 is reasonable. For CV generators and processors, 256 is reasonable.
For sequencers, 32 is reasonable since process() will be called every 0.7ms with a 44100kHz sample rate, which will capture 1ms-long triggers. For sequencers, 32 is reasonable since process() will be called every 0.7ms with a 44100kHz sample rate, which will capture 1ms-long triggers.
For audio generators and processors, 1-8 is recommended, but it will consume lots of CPU. For audio generators and processors, 1-8 is recommended, but it will consume lots of CPU.
If this is too slow for your purposes, you should just write a C++ plugin.
If this is too slow for your purposes, consider writing a C++ plugin, since native VCV Rack plugins are 10-100 faster.
*/ */
config.frameDivider // 32 config.frameDivider // 32


@@ -86,7 +86,7 @@ function process(args) {


## License ## License


All **source code** is copyright © 2019 Andrew Belt and licensed under the [BSD-3-Clause License](https://opensource.org/licenses/BSD-3-Clause).
All **source code** is copyright © 2019 VCV Prototype Maintainers and licensed under the [BSD-3-Clause License](https://opensource.org/licenses/BSD-3-Clause).


The **panel graphics** in the `res` directory are copyright © 2019 [Grayscale](http://grayscale.info/) and licensed under [CC BY-NC-ND 4.0](https://creativecommons.org/licenses/by-nc-nd/4.0/). The **panel graphics** in the `res` directory are copyright © 2019 [Grayscale](http://grayscale.info/) and licensed under [CC BY-NC-ND 4.0](https://creativecommons.org/licenses/by-nc-nd/4.0/).
You may not distribute modified adaptations of these graphics. You may not distribute modified adaptations of these graphics.


+ 3
- 0
src/DuktapeEngine.cpp View File

@@ -63,6 +63,7 @@ struct DuktapeEngine : ScriptEngine {
duk_push_string(ctx, path.c_str()); duk_push_string(ctx, path.c_str());
if (duk_pcompile_lstring_filename(ctx, 0, script.c_str(), script.size()) != 0) { if (duk_pcompile_lstring_filename(ctx, 0, script.c_str(), script.size()) != 0) {
const char* s = duk_safe_to_string(ctx, -1); const char* s = duk_safe_to_string(ctx, -1);
rack::WARN("duktape: %s", s);
setMessage(s); setMessage(s);
duk_pop(ctx); duk_pop(ctx);
return -1; return -1;
@@ -70,6 +71,7 @@ struct DuktapeEngine : ScriptEngine {
// Execute function // Execute function
if (duk_pcall(ctx, 0)) { if (duk_pcall(ctx, 0)) {
const char* s = duk_safe_to_string(ctx, -1); const char* s = duk_safe_to_string(ctx, -1);
rack::WARN("duktape: %s", s);
setMessage(s); setMessage(s);
duk_pop(ctx); duk_pop(ctx);
return -1; return -1;
@@ -209,6 +211,7 @@ struct DuktapeEngine : ScriptEngine {
// Call process function // Call process function
if (duk_pcall(ctx, 1)) { if (duk_pcall(ctx, 1)) {
const char* s = duk_safe_to_string(ctx, -1); const char* s = duk_safe_to_string(ctx, -1);
rack::WARN("duktape: %s", s);
setMessage(s); setMessage(s);
duk_pop(ctx); duk_pop(ctx);
return -1; return -1;


+ 2
- 0
src/Prototype.cpp View File

@@ -73,6 +73,7 @@ struct Prototype : Module {
// Check for certain inside the mutex // Check for certain inside the mutex
if (scriptEngine) { if (scriptEngine) {
if (scriptEngine->process(scriptArgs)) { if (scriptEngine->process(scriptArgs)) {
WARN("Script %s process() failed. Stopped script.", path.c_str());
clearScriptEngine(); clearScriptEngine();
return; return;
} }
@@ -108,6 +109,7 @@ struct Prototype : Module {
clearScriptEngine(); clearScriptEngine();
// Get ScriptEngine from path extension // Get ScriptEngine from path extension
if (path == "") { if (path == "") {
// Empty path means no script is requested. Fail silently.
return; return;
} }
INFO("Loading script %s", path.c_str()); INFO("Loading script %s", path.c_str());


+ 4
- 0
tests/process_error.js View File

@@ -0,0 +1,4 @@

function process(args) {
args.test()
}

+ 1
- 0
tests/run_error.js View File

@@ -0,0 +1 @@
test()

+ 1
- 0
tests/syntax_error.js View File

@@ -0,0 +1 @@
.test()

Loading…
Cancel
Save