Find file
Fetching contributors…
Cannot retrieve contributors at this time
48 lines (37 sloc) 1.14 KB

Hello World

This is an example of "Hello World" implemented with JavaScript and mweave.js


    console.log("Hello World");

Processing this with the command--

    node cli.js

Should yield the script helloworld.js containing only

    console.log("Hello World");

Let us tes this!

We are just going to pop open the results and see if they are what we expect.


    var fs = require("fs");
    fs.readFile("helloworld.js", function (err, buf) {
        var expected, s;
        if (err) {
            console.error("Test filed on helloworld.js: " + err);
        expected = 'console.log("Hello World");';
        s = buf.toString();
        if (s === expected) {
            console.log("Yippee! helloworld.js was rendered correctly!");
        } else {
            console.error("Something went wrong.");
            console.error("      s: [" + s + "]");
            console.error("expected [" + expected + "]");