1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
+
-
+
+
+
+
+
-
|
/* =================================================== -*- C++ -*-
* tcl.js "A Tcl implementation in Javascript"
*
* Released under the same terms as Tcl itself.
* (BSD license found at <http://www.tcl.tk/software/tcltk/license.html>)
*
* Based on Picol by Salvatore Sanfilippo (<http://antirez.com/page/picol>)
* (c) Stéphane Arnold 2007
* Richard Suchenwirth 2007, 2013: cleanup, additions
* vim: syntax=javascript autoindent softtabwidth=4
*/
// 'use strict'; // breaks some tests, like expr 0376, for loop
var _step = 0; // set to 1 for debugging
if(process.env["DEBUG"] == 1) _step = 1;
var fs = require('fs');
var puts = console.log;
var puts = console.log; // saves a lot of typing... ;^)
function TclInterp () {
this.patchlevel = "0.5.3";
this.callframe = [{}];
this.level = 0;
this.levelcall = [];
this.commands = {};
this.procs = [];
this.script = "";
this.getsing = 0;
this.OK = 0;
this.RET = 1;
this.BRK = 2;
this.CNT = 3;
this.getVar = function(name) {
var nm = name.toString();
// no arrays supported yet, but a read-only exception for ::env()
if (nm.match("^::env[(]")) nm = nm.substr(2);
if (nm.match("^env[(]")) {
var key = nm.substr(4,nm.length-5);
var val = process.env[key];
} else if (nm.match("^::")) {
var val = this.callframe[0][nm.substr(2)]; // global
} else {
var val = this.callframe[this.level][name];
}
if (val == null) throw 'can\'t read "'+name+'": no such variable';
return val;
}
this.setVar = function(name, val) {
var nm = name.toString();
if (val != null && val.toString().match(/\\/))
val = eval("'"+val.toString()+"'");
if (nm.match("^::")) {
this.callframe[0][nm.substr(2)] = val;
} else {this.callframe[this.level][name] = val;}
return val;
}
this.setVar("argc", process.argv.length-2);
this.setVar("argv0", process.argv[1]);
this.setVar("argv", process.argv.slice(2));
this.setVar("errorInfo", "");
this.incrLevel = function() {
//puts("going down from ("+this.level+"): "+this.levelcall);
this.callframe[++this.level] = {};
return this.level;
}
this.decrLevel = function() {
this.callframe[this.level] = null;
this.level--;
if (this.level < 0) throw "Exit application";
|
︙ | | |
102
103
104
105
106
107
108
109
110
111
112
113
114
115
|
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
|
+
|
} catch (e) {
var msg = code.substr(0,128);
if(msg.length >= 125) msg += "...";
var msg = e+'\n while executing\n"'+msg+'"';
for(var i = this.level; i > 0; i--)
msg += '\n invoked from within\n"'+this.levelcall[i]+'"'
this.setVar("::errorInfo", msg);
if(_step) puts("e: "+e);
throw e;
}
}
this.eval2 = function(code) {
this.code = this.OK;
var parser = new TclParser(code);
var args = [];
|
︙ | | |
168
169
170
171
172
173
174
175
176
177
178
179
180
181
|
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
|
+
+
+
+
+
|
args[args.length-1] = args[args.length-1].toString() + text.toString();
}
}
if (args.length > 0) result = this.call(args);
return this.objectify(result);
}
//---------------------------------- Commands in alphabetical order
/*this.registerCommand("after", function (interp, args) {
this.arity(args, 3);
var code = args[2].toString();
setTimeout(args[1], function(code) {interp.eval(code)});
});*/
this.registerCommand("append", function (interp, args) {
this.arity(args, 2, Infinity);
var vname = args[1].toString();
try {var str = interp.getVar(vname);} catch(e) {var str = "";}
for (var i = 2; i < args.length; i++) str += args[i].toString();
interp.setVar(vname, str);
return str;
|
︙ | | |
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
|
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
|
-
-
+
+
+
+
|
});
this.registerCommand("continue", function (interp, args) {
interp.code = interp.CNT;
return;
});
this.registerSubCommand("clock", "format", function (interp, args) {
var now = new Date();
now.setTime(args[1]);
return now.toString();
now.setTime(args[1]*1000);
var ts = now.toString().split(" ");
var tz = ts[6].toString().replace("(","").replace(")","");
return ts[0]+" "+ts[1]+" "+ts[2]+" "+ts[4]+" "+tz+" "+ts[3];
});
this.registerSubCommand("clock", "milliseconds", function (interp, args) {
var t = new Date();
return t.valueOf();
});
this.registerSubCommand("clock", "scan", function (interp, args) {
return Date.parse(args[1]);
|
︙ | | |
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
|
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
|
+
-
+
-
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
|
var sqrt = Math.sqrt; // "publish" other Math.* functions as needed
this.registerCommand("expr", function (interp, args) {
var expression = args.slice(1).join(" ");
return interp.expr(interp, expression);
});
this.expr = function (interp, expression) { // also used in for, if, while
var mx;
try {
var mx = expression.match(/(\[.*\])/g);
mx = expression.match(/(\[.*\])/g);
for (var i in mx)
puts("have to deal with "+mx[i].toString());
} catch(e) {puts(i+". exception: "+e);}
mx = expression.match(/(\$[A-Za-z0-9_:]+)/g);
for (i in mx) {
for (var i in mx) {
var val = interp.getVar(mx[i].slice(1)).toString();
if(isNaN(val) || !isFinite(val)) val = '"'+val+'"';
eval("var "+mx[i]+' = '+val);
}
var res = eval(expression);
if(res == false) res = 0; else if(res == true) res = 1;
return res;
};
this.registerSubCommand("file", "atime", function (interp, args) {
this.arity(args, 2);
var stat = fs.statSync(args[1].toString());
return stat.atime.getTime()/1000;
})
this.registerSubCommand("file", "dirname", function (interp, args) {
this.arity(args, 2);
return interp.dirname(args[1].toString());
});
this.dirname = function(p) { // also used in [glob]
//require("path"); //not working :(
//return path.dirname(p.toString());
if(p == ".") p = process.cwd();
var path = args[1].toString().split("/");
path.pop();
return path.join("/");
p = p.split("/");
p.pop();
if(p == "") return("/");
return p.join("/");
};
this.registerSubCommand("file", "exists", function (interp, args) {
this.arity(args, 2);
var file = args[1].toString();
try {var fd = fs.openSync(file,"r");} catch(e) {return 0;}
fs.closeSync(fd);
return 1;
});
this.registerSubCommand("file", "extension", function (interp, args) {
this.arity(args, 2);
var fn = args[1].toString();
var res = fn.split(".").pop();
res = (res == fn)? "" : "."+res;
return res;
});
this.registerSubCommand("file", "mtime", function (interp, args) {
this.arity(args, 2);
var stat = fs.statSync(args[1].toString());
return stat.mtime.getTime()/1000;
})
this.registerSubCommand("file", "size", function (interp, args) {
this.arity(args, 2);
var stat = fs.statSync(args[1].toString());
return stat.size;
})
this.registerSubCommand("file", "tail", function (interp, args) {
this.arity(args, 2);
return args[1].toString().split("/").pop();
});
this.registerCommand("for", function (interp, args) {
this.arity(args, 5);
interp.eval(args[1].toString());
if(interp.code != interp.OK) return;
var cond = args[2].toString();
var step = args[3].toString();
|
︙ | | |
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
|
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
|
-
-
-
+
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
|
var x = new Number(val);
return x.toString(16);
} else if(fmt=="%X") {
var x = new Number(val);
return x.toString(16).toUpperCase();
}
else throw "unknown format";
});
/*
this.registerCommand("gets", function (interp, args) {
this.registerCommand("gets0", function (interp, args) {
this.arity(args, 2, 3);
this.tmp = null;
rl.on('line', itp.gets);
while(true) {
if(this.tmp != null) break;
};
rl.on('line', this.getsevalputs);
var reply = this.tmp;
// = prompt(args[1],"");
//process.stdin.resume();
interp.getsing = 1;
//interp.buf = "";
//while(interp.buf == "") {
//interp.timeout = setTimeout(function(){}, 10000);
// if(interp.getsing==0) break;
//}
return; // result will be in interp.buf when done
});
this.gets = function(char) {
try {
if(char.match(/foo[\r\n]/)) {
this.getsing = 0;
puts("received: "+this.buf);
} else {
puts("<"+char+">"+this.getsing);
this.buf += char;
}
} catch(e) {puts(e)};
}
this.registerCommand("glob", function (interp, args) {
this.arity(args, 2, Infinity);
args.shift();
//process.stdin.on('data', function(str) {
//reply = str;
// });
if(args[2] != null) {
interp.setVar(args[2],interp.objectify(reply));
return reply.length;
var res = [];
var prefix = "";
var dir = ".";
for (var arg in args) {
var path = args[arg].toString();
if(path.match("[/]")) {
var dir = interp.dirname(path);
var prefix = dir+"/";
}
var pattern = path.split("/").pop().replace(/[*]/g,".*");
var files = fs.readdirSync(dir);
for (var i in files) {
if(files[i].match("^[.]")) continue;
if(files[i] == pattern) {res.push(files[i]);}
if(files[i].match("^"+pattern+"$")) {
var file = (dir == ".")? files[i] : dir+"/"+files[i];
res.push(file.replace(/\/\//,"/"));
}
}
}
return res;
} else return reply;
});
*/
this.registerCommand("if", function (interp, args) {
this.arity(args, 3, Infinity);
var cond = args[1].toString();
var test = interp.objectify(interp.expr(interp, cond));
if (test.toBoolean()) return interp.eval(args[2].toString());
if (args.length == 3) return;
for (var i = 3; i < args.length; ) {
|
︙ | | |
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
|
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
|
-
+
|
return interp.mkList(interp.procs);
});
this.registerSubCommand("info", "script", function (interp, args) {
return interp.script;
});
this.registerSubCommand("info", "vars", function (interp, args) {
var res = [];
for(i in interp.callframe[interp.level]) {
for(var i in interp.callframe[interp.level]) {
try {
if(interp.getVar(i) != null) {res.push(i);}
} catch(e) {};
}
return res;
});
this.registerCommand("join", function (interp, args) {
|
︙ | | |
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
|
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
|
-
+
+
|
if (args.length == 3) interp.setVar(name, val);
return interp.getVar(name);
});
this.registerCommand("source", function (interp, args) {
this.arity(args, 2);
interp.script = args[1].toString();
try {
var data = fs.readFileSync(interp.script).toString();
var data = fs.readFileSync(interp.script,{encoding: 'utf8'}).toString();
} catch(e) {
puts("e: "+e);
throw 'couldn\' read file "'+interp.script
+'": no such file or directory';}
var res = interp.eval(data);
interp.script = "";
return res;
});
this.registerCommand("split", function (interp, args) {
|
︙ | | |
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
|
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
|
-
+
|
Tcl.isDecimal = new RegExp("^[+\\-]?[1-9][0-9]*$");
Tcl.isHex = new RegExp("^0x[0-9a-fA-F]+$");
Tcl.isOctal = new RegExp("^[+\\-]?0[0-7]*$");
Tcl.isHexSeq = new RegExp("[0-9a-fA-F]*");
Tcl.isOctalSeq = new RegExp("[0-7]*");
Tcl.isList = new RegExp("[\\{\\} ]");
Tcl.isNested = new RegExp("^\\{.*\\}$");
Tcl.getVar = new RegExp("^[a-zA-Z0-9_]+", "g");
Tcl.getVar = new RegExp("^[:a-zA-Z0-9_]+", "g");
Tcl.Proc = function (interp, args) {
var priv = this.privdata;
interp.incrLevel();
var arglist = priv[0].toList();
var body = priv[1];
var call = [];
|
︙ | | |
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
|
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
|
-
|
var sub = args[1].toString();
var main = args.shift().toString()+" "+sub;
args[0] = main;
var ens = this.ensemble;
if (ens == null) {
throw "Not an ensemble command: "+main;
} else if (ens[sub] == null) {
var matches = 0, lastmatch = "";
for (var i in ens) { // maybe unambiguous prefix?
if (i.match("^"+sub) != null) {
matches += 1;
lastmatch = i;
}
}
|
︙ | | |
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
|
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
|
-
-
-
+
+
+
|
function TclCommand(func, privdata) {
if (func == null) throw "No such function";
this.func = func;
this.privdata = privdata;
this.ensemble = arguments[2];
this.call = function(interp, args) {
var r = (this.func)(interp, args);
r = interp.objectify(r);
return r;
var res = (this.func)(interp, args);
res = interp.objectify(res);
return res;
}
this.arity = function (args, min, max) {
if(max == undefined) max = min;
if (args.length < min || args.length > max) {
throw min + ".."+max + " words expected, got "+args.length;
}
}
|
︙ | | |
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
|
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
|
-
-
+
|
}
if (this.cur == "#" && this.type == this.EOL) {
this.parseComment();
continue;
}
return this.parseString();
}
puts("unreachable?");
return this.OK; // unreached
//return this.OK; // unreached
}
this.feedSequence = function () {
//return;
if (this.cur != "\\") throw "Invalid escape sequence";
var cur = this.steal(1);
puts("enter feedSequence, text: "+this.text+" cur: "+cur);
var specials = {};
|
︙ | | |
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
|
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
|
-
+
+
+
-
+
-
-
-
-
-
-
+
+
+
+
-
-
-
|
process.argv.slice(2).forEach(function(cmd,index,array) {
itp.eval(cmd);
});
var readline = require('readline');
var rl = readline.createInterface(process.stdin, process.stdout);
rl.setPrompt('% ');
rl.prompt();
itp.getsevalputs = function(line) {
itp.gets = function(line) {
if (itp.getsing == 0) {
try {
res = itp.eval(line.trim());
} catch(e) {res = e;}
if (itp.getsing == 0) {
if(res != null && res.toString() != "" && res.toString().length)
if(res != null && res.toString().length)
puts(res.toString());
rl.prompt();
};
itp.gets = function(line) {
puts("received "+line);
this.tmp = line;
}
rl.on('line', itp.getsevalputs
}
} else {itp.buf = line; itp.getsing = 0; rl.prompt();}
};
rl.on('line', itp.gets).on('close',function() {process.exit(0);});
).on('close',function() {
process.exit(0);
});
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
-
+
+
-
+
-
-
+
+
+
+
+
+
-
|
# test suite for TclJS
# This file is designed so it can also run in a tclsh. Some JavaScript goodies,
# like 1/0, sqrt(-1) were excluded from the tests.
# [clock format 0] was excluded because the timezone string differed.
set vars [info vars] ;# for later cleanup
set version 0.5.3
set total 0
set passed 0
set fail 0
puts "------------------------ [info script] patchlevel: [info patchlevel]"
puts "----- [info script] of [clock format [file mtime [info script]]], patchlevel: [info patchlevel]"
proc e.g. {cmd -> expected} {
#puts $cmd
incr ::total
incr ::fail ;# to also count exceptions
set res [uplevel 1 $cmd]
if ![string equal $res $expected] {
#if {$res != $expected} {} #should work, but wouldn't
#if {$res != $expected} {}
puts "**** $cmd -> $res, expected: $expected"
} else {incr ::passed; incr ::fail -1}
}
# e.g. {exec echo hello} -> hello ;# needs blocking exec
e.g. {append new hello} -> hello
e.g. {set x foo} -> foo
e.g. {append x bar} -> foobar
proc sum args {expr [join $args +]}
e.g. {sum 1 2 3} -> 6
#native sum2 {function (interp, args) {return eval(args.join("+"));}}
#e.g. {sum2 2 3 4} -> 9
e.g. {catch foo msg} -> 1
e.g. {set msg} -> {invalid command name "foo"}
e.g. {catch {expr 7*6}} -> 0
e.g. {catch {expr 7*6} msg; set msg} -> 42
e.g. {clock format 0} -> {Thu Jan 01 01:00:00 CET 1970}
e.g. {concat {a b} {c d}} -> {a b c d}
e.g. {concat $::version} -> $version
e.g. {set d [dict create a 1 b 2 c 3]} -> {a 1 b 2 c 3}
e.g. {dict exists $d c} -> 1
e.g. {dict exists $d x} -> 0
e.g. {dict get $d b} -> 2
e.g. {dict keys $d} -> {a b c}
e.g. {dict set d b 5} -> {a 1 b 5 c 3}
e.g. {dict set d x 7} -> {a 1 b 5 c 3 x 7}
e.g. {dict unset d b} -> {a 1 c 3 x 7}
e.g. {dict unset d x} -> {a 1 c 3}
e.g. {dict unset d nix} -> {a 1 c 3}
e.g. {dict set dx a 1} -> {a 1} ;# create new dict if not exists
e.g. {set home [file dirname [pwd]]; list} -> {}
e.g. {string equal [set env(HOME)] $home} -> 1
# e.g. {string equal $::env(HOME) $home} -> 1
e.g. {string equal [set ::env(HOME)] $home} -> 1
e.g. {file dirname /foo/bar/grill} -> /foo/bar
e.g. {file tail /foo/bar/grill} -> grill
e.g. {expr 6*7} -> 42
e.g. {expr {6 * 7 + 1}} -> 43
e.g. {set x 43} -> 43
e.g. {expr {$x-1}} -> 42
e.g. {expr $x-1} -> 42
if ![info exists auto_path] { ;#these tests are not for a real tclsh
e.g. {clock format 0} -> {Thu Jan 01 1970 01:00:00 GMT+0100 (CET)}
e.g. {set i [expr 1/0]} -> Infinity
e.g. {expr $i==$i+42} -> 1
e.g. {set n [expr sqrt(-1)]} -> NaN
e.g. {expr $n == $n} -> 0
e.g. {expr $n==$n} -> 0
e.g. {expr $n!=$n} -> 1
e.g. {info patchlevel} -> $version
|
︙ | | |
89
90
91
92
93
94
95
96
97
98
99
100
101
102
|
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
|
+
+
+
+
+
+
|
e.g. {expr $x+1} -> 4
e.g. {expr {$x+1}} -> 4
e.g. {set x a; set y b; expr {$x == $y}} -> 0
e.g. {expr {$x != $y}} -> 1
e.g. {expr 43 % 5} -> 3
e.g. {set x -44; expr {-$x}} -> 44
e.g. {expr 1<<3} -> 8
e.g. {file dirname foo/bar/grill} -> foo/bar
e.g. {file dirname /foo/bar/grill} -> /foo/bar
e.g. {file extension foo.txt} -> .txt
e.g. {file extension Makefile} -> ""
e.g. {file tail foo/bar/grill} -> grill
set forres ""
e.g. {for {set i 0} {$i < 5} {incr i} {append forres $i}; set forres} -> 01234
e.g. {foreach i {a b c d e} {append foreachres $i}; set foreachres} -> abcde
e.g. {format %x 255} -> ff
e.g. {format %X 254} -> FE
|
︙ | | |
138
139
140
141
142
143
144
145
146
147
148
149
150
151
|
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
|
+
|
e.g. {lsearch $x y} -> -1
e.g. {lsort {z x y}} -> {x y z}
e.g. {proc f args {expr [join $args +]}} -> ""
e.g. {f 1} -> 1
e.g. {f 1 2} -> 3
e.g. {f 1 2 3} -> 6
e.g. {proc f {arg b} {expr $arg*$b}; f 6 7} -> 42 ;# should work with 'args'
e.g. {regexp {X[ABC]Y} XAY} -> 1
e.g. {regexp {X[ABC]Y} XDY} -> 0
e.g. {regsub {[A-C]+} uBAAD x} -> uxD
e.g. {split "a b c d"} -> {a b {} c d}
e.g. {split " a b c d"} -> {{} a b {} c d}
|
︙ | | |
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
|
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
|
+
-
+
+
+
-
-
+
|
e.g. {string compare b b} -> 0
e.g. {string equal foo foo} -> 1
e.g. {string equal foo bar} -> 0
e.g. {string index abcde 2} -> c
e.g. {string length ""} -> 0
e.g. {string length foo} -> 3
e.g. {string range hello 1 3} -> ell
e.g. {string range hello 1 end} -> ello
e.g. {string tolower Tcl} -> tcl
e.g. {string toupper Tcl} -> TCL
e.g. {string trim " foo "} -> foo
e.g. {set x a.\x62.c} -> a.b.c ;# severe malfunction, breaks test suite operation :(
e.g. {set x a.\x62.c} -> a.b.c
e.g. {set e \u20ac} -> "€" ;# breaks in node v0.6.19, works in v0.10.22
puts "total $total tests, passed $passed, failed $fail"
#----------- clean up variables used in tests
foreach var [info vars] {
set pos [lsearch $vars $var] ;# expr can't substitute commands yet
set neq [string compare $var vars]
if {$var != "vars" && $pos < 0} {unset $var}
}
unset vars var pos neq
unset vars var pos
puts "vars now: [info vars]"
puts "[llength [info commands]] commands implemented"
|