 #language "lang/plush/0"
 
 var str = import "std/string/0";
+var array = import "std/array/0";
+var arrayEq = array.arrayEq;
 
-//Utility functions
-var arrayeq = function(a, b)
+var assertThrows = function (fun)
 {
-    if (a.length != b.length)
+    var threw = false;
+    try
     {
-        return false;
+        fun();
     }
-    for (var i = 0; i < a.length; i += 1)
+    catch (e)
     {
-        if (a[i] != b[i])
-        {
-            return false;
-        }
+        threw = true;
     }
-    return true;
+    assert (threw);
 };
 
 var indexOf = str.indexOf;

assert(parseInt("-123", 10) == -123);
assert(parseInt("a", 16) == 10);
assert(parseInt("1010", 2) == 10);

try
{
    parseInt("", 10);
    assert(false);
}
catch(e)
{
    assert(true);
}
try
{
    parseInt("123abc", 10);
    assert(false);
}
catch(e)
{
    assert(true);
}

var parseFloat = str.parseFloat;
assert (parseFloat("0") == 0.0f);

assert(rpad("Hello", ".", 7) == "Hello..");
assert(rpad("Hello", " ", 3) == "Hello");
assert(rpad("Hello", " ", -1) == "Hello");
assertThrows(function () { rpad("Hello", "", 7); });
assertThrows(function () { rpad("Hello", "abcd", 7); });

var startsWith = str.startsWith;
assert(startsWith("Banana", "Ban"));
