node package manager

rjst

rjst

runtime.js testing/playground

Startup

./scripts/start.js
# or, if you don't want to copy over Work-In-Progress runtime.js:
./scripts/start.js --no-cpr # or `npm start` will also do this

Currently Included Kernel

Branch kernel-improvements

Features in this kernel but not in the distributed version:

  • require builtin to the kernel, without needing to load the runtimejs library
  • global.onrejectionhandle and global.onunhandledrejection
  • Various other kernel improvements

V8 flags currently set in runtime.json:

  • WebAssembly support (--expose-wasm)
  • Async/await support (--harmony-async-await)

Note

Commands in the testing groups can only be used if they're verified and can be used.

Testing Groups

http

Testing for a node compatible HTTP module (PR #103)

Commands

  • client - Makes a request to 'http://httpbin.org/ip', might hang if response never arrives (issue with the implementation).
  • server - Sets up a server to serve index.html and script.js from /srv/public on port 8080.

Verifier Check

http module can be require()ed, or the polyfill (/usr/lib/polyfill/http) can be required()ed.

cryptoTests

Tests for libsodium crypto (PR #83)

Commands

  • cryptoTests - Runs tests on the libsodium crypto implementation, outputs results to the console.

Verifier Check

libsodium object is present in runtime.

wasm

  • Required Kernel - >= Commit e5e1496 with a patch (or master/distributed kernel with --expose-wasm in v8.flags in runtime.json)

WebAssembly testing (Issue #111)

Note: Web Assembly testing is disabled by default since it significantly slows down startup time. To enable it, you must edit cmds.json and remove all the lines that say "disabled": true for the Web Assembly commands.

Commands

  • helloWorld - Outputs "Hello, world!" to the console. Binaryen compiled C++ to WebAssembly version.
  • helloWorldThinscript - Outputs "Hello, world!" to the console. Compiled ThinScript to WebAssembly version.
  • output - Outputs "Hi there!" 300 times to the console. Binaryen compiled C++ to WebAssembly version.
  • outputThinscript - Outputs "Hi there!" 300 times to the console. Compiled ThinScript to WebAssembly version.

Verifier Check

Global Wasm object is present.

asyncAwait

  • Required Kernel - >= Commit e5e1496 compiled with an extra flag (--harmony-async-await) (or master/distributed kernel with --harmony-async-await in v8.flags in runtime.json)

ES7 Async Functions and Await support testing.

Commands

  • sleepABit - Outputs a message, "sleeps" for 7 seconds, and outputs another message and exits.

Verifier Check

evaluating an async function that also awaits (async function foobar() {await foo();}) compiles without a SyntaxError.

graphics

Graphics! Pixel manipulation, fillRecting, image drawing... all that good stuff. (PR #130)

Commands

  • compareFillRects - Compares the 2 methods of fillRecting, and logs the execution time to the console.
  • drawImage - Draws a test image to the screen.

Verifier Check

runtime.graphics is present, the typeof runtime.graphics.graphicsAvailable is a function, and runtime.graphics.graphicsAvailable() returns true.

mouse

PS2 mouse. Mainly useful in combination with graphics.

Commands

  • doubleClick - Requires the user to double-click two times in order to return the command prompt.

Verifier Check

runtime.mouse is an object.

block

  • Required Library - Master library

Block device (disk) drivers! Yay, persistency!

Note

In order to use block, you must create a disk image formatted with a single FAT{16,32} partition and the filename must be disk.img (so the start script will detect it). However, you can do this easily with runtime mkimg, like so:

# must be named disk.img, but it can be any
# size you want, with any label you want.
# see `runtime mkimg --help`
runtime mkimg disk.img --size 1G --label MYDISK

Bonus: runtime mkimg is cross-platform 😉

After doing so, you must also write a test file containing the same contents as usr/share/block/test.txt (probably just cp it) for the compareFiles test to work.

However, you can do all of this in one command, with the setupDisk script. It'll create the disk (with runtime mkimg), and create the necessary file(s). Like:

./scripts/setupDisk.js
# on some systems you many need to have root privileges:
sudo ./scripts/setupDisk.js

Commands

  • compareFiles - Compares 2 test text files, one from memory, the other from the disk, to see if they equal. Basically, it's a disk sanity check.

Verifier Check

runtime.block is an object.

Multi-Group Commands

graphicCursor

Groups

  • graphics
  • mouse

Description

Draws a white pixel where the cursor is placed, and repaints when the user moves the mouse.