Test of basic features of the language

//|
//| String test
//|
"hello""world"" ""hello world""concat""l""indexOf 1""h""indexOf 2""h""indexOf 3""l""lastIndexOf""o""lastIndexOf""l""charAt""charCodeAt""plain""fromCharCode"// range test
"hello world""llo""range 1""hello""range 2""world""range 3""The rain in Spain falls mainly in the plain"//Create regular expression pattern.
//Attempt match on search string.
"ain""match/i""match/gi""1""The r1 in Sp1 falls m1ly in the pl1""replace/gi""Spain""search 1""Russia""search 2""plain""slice 1""Spain""slice 2"" rain in Spain falls mainly in the plain""slice 3"" ""split1""split2""Spain""substr""Spain""substring""This is a STRING object""this is a string object""toLowerCase""This is a STRING object""THIS IS A STRING OBJECT""toUpperCase""This is a STRING object""This is a STRING object""toString""This is a STRING object""This is a STRING object""valueOf""Hello""Hello1""join""%v\n"// range test
"range 1""range 2""range 3""ctor1a, length=""ctor1b""ctor1c""ctor2a,""ctor2b""ctor2c""first get""last get""pop1""pop2""shift1""shift2""push""unshift""push/pop""concat1""concat2""-""0-1-2-3-4-5""join""reverse""slice""splice1""splice2""splice3""splice4""sort1""sort2""sort3 with lambda, arrays are %v %v\n""toLocaleString | toString""for(var in array)""Integer.MAX""Integer.MIN""314""toInteger""ABC""toInteger not integer string""ABC""toInteger not integer string, default value""remainder!""Integer.max""Integer.min""Integer.max sub array""Integer.min sub array""1.#INF""Float.MAX""-1.#INF""Float.MIN""3.14""toFloat""ABC""toFloat not float string""ABC""toFloat not float string, default value""Float.max""Float.min""Float.max sub array""Float.min sub array"// arg with the default value test
"Function, default parameters values"// varargs
//stdout << "args are:" << args;
//stdout << " typeof args is:" << typeof args << "\n";
"Function, varargs!"// varargs, rest
"Function, varargs 2!"// apply test #1
"Function, apply (0) failed !""Function, call (0) failed !"// apply test #2, additional parameters
"Function, apply (1) failed !""Function, call (1) failed !"// lambda tests
// simplest form  
"Lambda 1.1 failed !""Lambda 1.2 failed !"// second form of lambda declaration - block with parameters
"Lambda 2.1 failed !""Lambda 2.2 failed !"// third, classic lambda declaration
"Lambda 3.1 failed !""Lambda 3.2 failed !""o1""foo""foo:"//get part
// set part
// type 'Bar' is derived from 'Foo'
"o2""bar""bar""bar:"// classic class use cases
"class ctor 1""foo""class method 1""prototype/get 1""foo:o1""property/get 1""O1""foo:O1""property/set 1"// Bar is derived from Foo 
"class ctor 2.1""class ctor 2.2""bar""class method 2.1""foobar""class method 2.2""prototype/get 2""bar:o2""property/get 2""O2""bar:O2""property/set 2""typeof""instanceof 1""instanceof 2"// class literals and dynamic subclassing
"three""[object Object]""toString""literal 1""three""literal 2"// assign class to existing object instance.
// yep, it works in the script.
"foo""dynamic class change"// does copy!
"foo""clone""one""in"// non JS feature: literals of user defined classes
// this is actually short form of var o2 = {prototype:Class, one:1 };
"literal class 1 ""foo""literal class 2"// non JS feature: get element by literal 
"attribute by symbol 1 "// short form of the line above
"attribute by symbol 2 ""attribute by symbol 3 ""const 1""const 2""const 3"//next line shall produce compile time error.
//MY_LOCAL_CONST = 25;
"today is:%d-%d-%d %d:%d:%d\n""today is:%d-%d-%d %d:%d:%d\n""28 Feb 1980 UTC""date ctor""date is:%d-%d-%d %d:%d:%d\n""locale format short:%s\nlocale format long:%s\n""date is:%d-%d-%d %d:%d:%d\n"// in memory string stream, a.k.a. stram builder
"one""two""three""%d%d%d""onetwothree123""String Stream!"//too noisy but works
//var f = Stream.openFile( "tests.js", "r" );
//if(!f) 
//{
//  stdout.printf("unable to open file tests.js\n");
//  return;
//}
//while( true )
//{
//  var s = f.readln();
//  if(s == undefined) break;
//  stdout.println(s);
//}
//stdout.println("------------");
// print t in format suitable for 'eval'!
"return %v;\n"// will print content of front page:
"www.terrainformatica.com:80""GET http://www.terrainformatica.com/main.whtm HTTP/1.0""User-Agent: TiScript [en]""""."// namespace
"namespace 1""Test '%s' passed\n""Test '%s' failed on '%s'!\n"// test GC
//This is too noisy, so I've commented it out for a while.
//run( SocketStream_test );
 

tiscript/test_of_basic_functions.txt · Last modified: 2007/09/21 22:40 (external edit)
chimeric.de = chi`s home Creative Commons License Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0