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
|
// =============================================================================
// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
// Copyright (C) 2007-2008 - INRIA
//
// This file is distributed under the same license as the Scilab package.
// =============================================================================
// <-- CLI SHELL MODE -->
//===============================
// unit tests tokens
//===============================
if tokens('This is a character string') <> ['This'; 'is'; 'a'; 'character'; 'string'] then bugmes();quit;end
if tokens('SCI/demos/scicos','/') <> ['SCI';'demos';'scicos'] then bugmes();quit;end
if tokens('y=a+b*2',['=','+','*']) <> ['y';'a';'b';'2'] then bugmes();quit;end
if length(tokens('',['=','+','*'])) <> 0 then bugmes();quit;end
//===============================
if tokens(' ',' ') <> [] then bugmes();quit;end
//===============================
s = tokens(' '+ascii(9)+' ',ascii(9));
if s <> [' '; ' '] then bugmes();quit;end
//===============================
s = tokens(' '+ascii(9)+' ',' ');
if s <> ascii(9) then bugmes();quit;end
//===============================
s = tokens(' '+ascii(9)+' ',ascii(9));
if s <> [' '; ' '] then bugmes();quit;end
//===============================
s = tokens(' '+ascii(9)+' ',' ');
if s <> ascii(9) then bugmes();quit;end
//===============================
str = "世界您好";
ch = "界";
r = tokens(str,ch);
ref = ["世";"您好"];
if and(ref <> r) then bugmes();quit;end
//===============================
str = "азеазея";
ch = "з";
r = tokens(str,ch);
ref = ["а";"еа";"ея"];
if and(ref <> r) then bugmes();quit;end
//===============================
str = "ハロー・ワールド";
ch = "ワ";
r = tokens(str,ch);
ref = ["ハロー・";"ールド"];
if and(ref <> r) then bugmes();quit;end
//===============================
str = "เฮลโลเวิลด์";
ch = "ฮ";
r = tokens(str,ch);
ref = ["เ";"ลโลเวิลด์ "];
if and(ref <> r) then bugmes();quit;end
//===============================
str = "حريات وحقوق";
ch = "و";
r = tokens(str,ch);
ref = ["حريات";"حق";"ق"];
if and(ref <> r) then bugmes();quit;end
//===============================
str = "תוכנית";
ch = "ו";
r = tokens(str,ch);
ref = ["ת";"כנית"];
if and(ref <> r) then bugmes();quit;end
//===============================
|