var sys = require('sys')
  , format = require('./format')
  ;
format.extendNativeStrings();

sys.puts('Testing printf:');
'hello'.printf();
sys.puts('(expected "hello")');
'hello %s'.printf('sami');
sys.puts('(expected "hello sami")');
'b: %b\nc: %c\nd: %d\nf: %f\no: %o\ns: %s\nx: %x\nX: %X'.printf(42, 65, 42*42, 42*42*42/1000000000, 255, 'sami', 0xfeedface, 0xc0ffee);
sys.puts('(expected "b: 101010\nc: A\nd: 1764\nf: 0.000074\no: 0377\ns: sami\nx: 0xfeedface\nX: 0xC0FFEE")');
sys.puts('(passed if the output looks ok)');

function assertEqual(a, b) {
    if (a !== b) throw new Error('assertion failed, ' + a + ' !== ' + b);
}

sys.puts('Testing format:');
assertEqual('hello'.format(), 'hello');
assertEqual('hello %s'.format('sami'), 'hello sami');
assertEqual('b: %b\nc: %c\nd: %d\nf: %f\no: %o\ns: %s\nx: %x\nX: %X'.format(42, 65, 42*42, 42*42*42/1000000000, 255, 'sami', 0xfeedface, 0xc0ffee), "b: 101010\nc: A\nd: 1764\nf: 0.000074\no: 0377\ns: sami\nx: 0xfeedface\nX: 0xC0FFEE");
sys.puts('(pass)');

sys.puts('all passed');
@@ -1,152 +1,126 @@
 var 
-sys = require('sys')%0A  , format = require('./format')%0A  ;%0Aformat.extendNativeStrings();%0A%0Asys.puts('Testing printf:');%0A'hello'.printf();%0Asys.puts
+format = require('./lib')%0A  , printf = format.printf%0A  ;%0A%0Aconsole.log('Testing printf:');%0Aprintf('hello');%0Aconsole.log
 ('(e
@@ -139,16 +139,23 @@
 lo%22)');%0A
+printf(
 'hello %25
@@ -156,24 +156,18 @@
 ello %25s'
-.printf(
+, 
 'sami');
@@ -167,24 +167,27 @@
 sami');%0A
-sys.puts
+console.log
 ('(expec
@@ -207,16 +207,23 @@
 mi%22)');%0A
+printf(
 'b: %25b%5Cn
@@ -274,16 +274,10 @@
  %25X'
-.printf(
+, 
 42, 
@@ -344,24 +344,27 @@
 0ffee);%0A
-sys.puts
+console.log
 ('(expec
@@ -457,24 +457,27 @@
 EE%22)');%0A
-sys.puts
+console.log
 ('(passe
@@ -612,24 +612,27 @@
  b);%0A%7D%0A%0A
-sys.puts
+console.log
 ('Testin
@@ -660,23 +660,22 @@
 ual(
-'hello'
+format
 .format(
 ), '
@@ -670,16 +670,23 @@
 .format(
+'hello'
 ), 'hell
@@ -702,16 +702,30 @@
 rtEqual(
+format.format(
 'hello %25
@@ -726,24 +726,18 @@
 ello %25s'
-.format(
+, 
 'sami'),
@@ -764,16 +764,30 @@
 rtEqual(
+format.format(
 'b: %25b%5Cn
@@ -834,24 +834,18 @@
 %5CnX: %25X'
-.format(
+, 
 42, 65, 
@@ -996,24 +996,27 @@
 FFEE%22);%0A
-sys.puts
+console.log
 ('(pass)
@@ -1024,16 +1024,19 @@
 );%0A%0A
-sys.puts
+console.log
 ('al
@@ -1046,8 +1046,9 @@
 assed');
+%0A

update tests (really need to be rewritten as proper tests)