cfad47cfa3/t3compiler/tads3/test/data/unicode.t

4b825dc642cb6eb9a060e54bf8d69288fbee4904cfad47cfa334b206c65f22086bcc5d63e6f70944
1
/*
2
 *   unicode conversion function tests 
3
 */
4
5
#include "tads.h"
6
#include "t3.h"
7
8
9
main(args)
10
{
11
    local p;
12
    local i;
13
    
14
    "makeString(42) = '<<makeString(42)>>'\n";
15
    "makeString([42, 43, 44]) = '<<makeString([42, 43, 44])>>'\n";
16
    "makeString('asdf') = '<<makeString('asdf')>>'\n";
17
18
    "makeString(42, 10) = '<<makeString(42, 10)>>'\n";
19
    "makeString([42, 43, 44], 10) = '<<makeString([42, 43, 44], 10)>>'\n";
20
    "makeString('abcd', 5) = '<<makeString('abcd', 5)>>'\n";
21
22
    p = [42, 43, 44];
23
    p += [55, 56, 57];
24
    "makeString(p[lst], 20) = '<<makeString(p, 20)>>'\n";
25
26
    p = 'Hello';
27
    p += '!!!';
28
    "makeString(p[str], 8) = '<<makeString(p, 8)>>'\n";
29
30
    "makeString([0x7000, 0x7001, 0x7002], 5) =
31
     '<<makeString([0x7000, 0x7001, 0x7002], 5)>>'\n";
32
33
    "\b";
34
35
    for (i = 1, p = 'asdf' ; i <= p.length() ; ++i)
36
        "'<<p>>'.toUnicode(<<i>>) = <<p.toUnicode(i)>>\n";
37
38
    "'<<p>>'.toUnicode() = <<sayList(p.toUnicode())>>\n";
39
40
    p = '\u7000\u7001abc\u7002\u7003def\xA8';
41
    "'<<p>>'.toUnicode() = <<sayList(p.toUnicode())>>\n";
42
}
43
44
sayList(lst)
45
{
46
    if (lst == nil)
47
        "nil";
48
    else
49
    {
50
        "[";
51
        for (local i = 1, local len = lst.length() ; i <= len ; ++i)
52
        {
53
            tadsSay(lst[i]);
54
            if (i != len)
55
                ", ";
56
        }
57
        "]";
58
    }
59
}
60
61
preinit()
62
{
63
}
64
65