[JW Lua] Unit-testing with jwlua scripts?

Nick Mazuk nick at nickmazuk.com
Sat Sep 11 21:26:58 CEST 2021


Hi Daniel,

Glad that you're interested in coding with JW Lua! Many of us also write these Lua scripts to implement features MakeMusic hasn't. Now about your questions.

*Unit testing*

Testing is a feature that's missing in JW Lua. Lua (the language that powers JW Lua) does have several testing frameworks you can use, but because JW Lua adds so many features on top of regular Lua, you likely won't be able to use any of these frameworks.

Currently, the best way to test JW Lua scripts is to create a Finale document with all your test cases, run the script, and manually compare the output to what you want. This is definitely not as good as automated testing, but it's better than nothing.

*OOP*

Lua does not have objects, classes, inheritance, or most other features you'd expect with object oriented programming. The closest thing is a "table" (like a dictionary in Python or a hash map in Javascript). So the code you write is mostly going to be functional (which realistically this works really well for JW Lua).

However, Finale it's self uses OOP. So JW Lua extends the Lua language with "Finale objects". Anytime you see something like `local entry = finale.FCNoteEntry()` , you are instantiating a new note entry object. You can check out the class browser (which is inside the plugin) for all the objects, methods, and properties that JW Lua adds.

Does this make sense?

Also, since you're coming from the C family of languages, note that Lua is much simpler. For instance, you don't need to keep track of memory management and Lua is not statically typed (e.g., you don't need to declare an integer as an int).

One thing you may wish to do is to contribute to a GitHub repository of Lua scripts that several of us have put together. We have a standard library of functions that takes care of many things that you might now want to do by hand (e.g., figuring out how to transpose notes). If you want to share your scripts, contributing to this repository makes it dead simple. Let me know if you want to learn more about it. https://github.com/Nick-Mazuk/jw-lua-scripts

Best,

Nick

On Sat, Sep 11, 2021 at 11:13 AM, < dgr at leng.de > wrote:

> 
> 
> 
> Hi guys,
> 
> 
> 
> 
> I am new to JWLua and Lua in general. (However I am not new to software
> development, see below.) I want to implement new features into Finale
> needed for classical guitar notation. I begged make music years ago to
> implement them. They told me liking my ideas but never implemented any of
> it. So I probably will have to go for myself because I am sick of the
> cumbersome and time-consuming editing due to lack of proper tools.
> 
> 
> 
> 
> I have been educated with C (mostly embedded), have little experience in
> C++ and am coding in C# currently. I read the programming in lua book but
> still have trouble to understand some of the concepts. Therefore I assume
> I will have to ask a lot of questions on this channel and will appreciate
> anyone who answers.
> 
> 
> 
> 
> Today my first question: Is there any kind of unit testing framework or
> alike to use inside JWLua? I am getting used to test-driven-development
> and would like to do this here as well, if possible.
> 
> 
> 
> 
> And second question: What is the best way to code object-oriented in
> JWLua?
> 
> 
> 
> 
> Thank for your kind help in advance.
> 
> 
> 
> 
> Daniel Grunwald
> 
> 
> 
> 
> _______________________________________________
> JWLua mailing list
> JWLua@ jwmusic. nu ( JWLua at jwmusic.nu )
> http:/ / jwmusic. nu/ mailman/ listinfo/ jwlua_jwmusic. nu (
> http://jwmusic.nu/mailman/listinfo/jwlua_jwmusic.nu )
> 
> 
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://jwmusic.nu/pipermail/jwlua_jwmusic.nu/attachments/20210911/51643227/attachment.htm>


More information about the JWLua mailing list