twinBASIC Update: August 29, 2021

Highlights include Unit Testing support, conditional breakpoints, the Nz() function, and various IntelliSense improvements.

twinBASIC Update: August 29, 2021

On April 23, 2021, I helped Wayne Phillips introduce the world to twinBASIC at the Access DevCon Vienna conference.  I boldly predicted that twinBASIC (along with the Monaco editor) would replace VBA and its outdated development environment by 2025.  With that goal in mind, this weekly update is my attempt to keep the project fresh in the minds of the VBA development community.

Every Sunday, I will be providing updates on the status of the project, linking to new articles discussing twinBASIC, and generally trying to increase engagement with the project.  If you come across items that should be included here, tweet me @NoLongerSet or email me at mike at nolongerset dot com.


Highlights

Unit Testing Goes Live!

While still considered an experimental feature, unit testing is now available in twinBASIC.  As part of its initial release, there are no setup/teardown methods yet and only module-based unit tests are supported.

You can choose how strict each assertion is by choosing one of three modes:

  • Exact
  • Strict
  • Permissive

Here are the rules for each of these modes:

Exact

  • String comparisons are case-sensitive
  • Object default members are not evaluated
  • There are no implicit conversions / coercions
  • The datatype of the compared values must match exactly (e.g. 5 <> 5.0)
  • vbNullString is considered to be unequal to a zero-length String ("")
  • Empty is considered to be unequal to zero- length Strings, vbNullString, zero and False

Tips

  • Null is never considered equal to anything, not even itself, so use the IsNull / IsNotNull assertions to test for it

Strict

  • String comparisons are case-sensitive
  • Object default members are not evaluated
  • Apart from the above exceptions, all other comparisons are evaluated as if done directly in twinBASIC code

Permissive

  • String comparisons are case-insensitive
  • All comparisons are evaluated as if done directly in twinBASIC code

The unit testing methods are based off of the Rubberduck Assert Class:

Name Description
AreEqual
Verifies that two specified objects are equal. The assertion fails if the objects are not equal.
AreNotEqual
Verifies that two specified objects are not equal. The assertion fails if the objects are equal.
AreNotSame
Verifies that two specified object variables refer to different objects. The assertion fails if they refer to the same object.
AreSame
Verifies that two specified object variables refer to the same object. The assertion fails if they refer to different objects.
Fail
Fails the assertion without checking any conditions.
Inconclusive
Indicates that the assertion cannot be verified.
IsFalse
Verifies that the specified condition is false. The assertion fails if the condition is true.
IsNothing
Verifies that the specified object is Nothing. The assertion fails if it is not Nothing.
IsNotNothing
Verifies that the specified object is not Nothing. The assertion fails if it is Nothing.
IsTrue
Verifies that the specified condition is true. The assertion fails if the condition is false.
NotSequenceEquals
Verifies that at least one of the items in 2 arrays differs at any give index. The assertion fails if all of the items are the same, if the lower bounds and upper bounds are the same, and the ranks (number of dimensions) are the same.
SequenceEquals
Verifies that all of the items in 2 arrays are equal. The assertion fails if any items is different, if either the lower bounds or upper bounds are different, or if the ranks (number of dimensions) differ.
Succeed
Passes the assertion without checking any conditions.

Conditional Breakpoints

From Wayne Phillips:

As of v0.10.5070, conditional breakpoints are now supported.

To set conditional breakpoints in VS Code, right click in the gutter (where you would normally click to set a breakpoint), and then you'll see the 'Add Conditional Breakpoint...' option.  Enter an expression such as 'Index > 500' and twinBASIC will only break at that line if that condition evaluates to TRUE.

Microsoft Access's Nz() Function Added

When I'm writing VBA in Excel or Word, I often forget that the Nz() function is specific to the Microsoft Access object model.  Beginning with v0.10.5101, the Nz() function is now available as part of twinBASIC's implementation of the VBA library.

IntelliSense Taming

One of the biggest challenges Wayne has had with IntelliSense within VS Code is that VS Code auto-selects the top item in the IntelliSense dropdown list when certain keys are pressed.  This behavior differed from VBx and seemed like an intractable limitation of the VS Code environment.

Wayne seems to have found a clever way around this limitation.  The first item in the IntelliSense dropdown is now the currently typed text.  Thus, auto-selecting this item will have no practical effect on the code being written.

Around the Web

Non-commercial / hobbyist License

Wayne opened a discussion about the possibility of adding a hobbyist tier that would sit between the free and professional tiers.  It would be a non-commercial license that would support 64-bit compilation, but not native compiler optimizations.

If this is something that would interest you, be sure to add your voice to the discussion.

Changelog

Here are the updates from the past week.  You can also find this information by installing the twinBASIC VS Code extension and clicking on the Changelog tab of the extension page:

[v0.10.5135, 29th August 2021]

[v0.10.5101, 28th August 2021]

[v0.10.5080, 27th August 2021]

[v0.10.5070, 27th August 2021]

[v0.10.5021, 26th August 2021]

[v0.10.5003, 26th August 2021]

[v0.10.5002, 26th August 2021]

[v0.10.4980, 25th August 2021]

[v0.10.4966, 24th August 2021]

[v0.10.4909, 24th August 2021]

[v0.10.4904, 24th August 2021]

[v0.10.4880, 23rd August 2021]

All original code samples by Mike Wolfe are licensed under CC BY 4.0