summaryrefslogtreecommitdiff
path: root/lib/std/test/chartype.myr
blob: 30426e67dfc24da737bcafd13b143e6760be090e (plain)
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
use std

const main = {
	std.assert(std.isalpha('a'), "a should be alpha\n")
	std.assert(std.isupper('A'), "A should be upper\n")
	std.assert(std.islower('a'), "a should be lower\n")
	std.assert(std.isdigit('0'), "0 should be isdigit\n")
	std.assert(std.isnum('\u{0c66}'), "\u{0c66} should be isnum\n")
	std.assert(std.isalnum('a'), "a should be isalnum\n")
	std.assert(std.isalnum('0'), "0 should be isalnum\n")
	std.assert(std.isspace(' '), "' ' should be isspace\n")
	std.assert(std.isblank(' '), "' ' should be isblank\n")

	std.assert(!std.isalpha('0'), "0 should not be alpha\n")
	std.assert(!std.isupper('a'), "a should not be upper\n")
	std.assert(!std.islower('A'), "A should not be lower\n")
	std.assert(!std.isdigit('a'), "a should not be isdigit\n")
	std.assert(!std.isnum('a'), " should not be isnum\n")
	std.assert(!std.isalnum('}'), "a should not be isalnum\n")
	std.assert(!std.isalnum('!'), "! should not be isalnum\n")
	std.assert(!std.isspace('@'), "@ should not be isspace\n")
	std.assert(!std.isblank('@'), "@ should not be isblank\n")

	std.assert(std.cellwidth(std.Badchar) == -1, "Badchar should have width -1\n")
	std.assert(std.cellwidth((0 : char)) == 0, "U+0000 should have width 0\n")
	std.assert(std.cellwidth('') == -1, "^E should have width -1\n")
	std.assert(std.cellwidth('a') == 1, "'a' should have width 1\n")
	std.assert(std.cellwidth('ê') == 1, "'ê' should have width 1\n")
	std.assert(std.cellwidth('̀') == 0, "U+300 should have width 0\n")
	std.assert(std.cellwidth('ϼ') == 1,  "ϼ should have width 1\n")
	std.assert(std.cellwidth('Ї') == 1, "Ї should have width 1\n")
	std.assert(std.cellwidth('⊲') == 1, "⊲ should have width 1\n")
	std.assert(std.cellwidth(' ') == 2, "U+3000 should have width 2\n")
	std.assert(std.cellwidth('ギ') == 2, "ギ should have width 2\n")
	std.assert(std.cellwidth('匌') == 2, "匌 should have width 2\n")
	std.assert(std.cellwidth('­') == 0, "U+00AD should have width 0\n")
	std.assert(std.cellwidth('ࠠ') == 0, "U+820 should have width 0\n")
	std.assert(std.cellwidth('־') == 1, "U+5BE should have width 1\n")
	std.assert(std.cellwidth('ֿ') == 0, "U+5BF should have width 0\n")
	std.assert(std.cellwidth('׀') == 1, "U+5C0 should have width 1\n")
}