Skip to content

Commit 2ea3f5e

Browse files
committed
Improve testing possibilities
Add derivedcoreproperties for testing purposes, will be used when testing is_ID* functionality.
1 parent 3579564 commit 2ea3f5e

File tree

4 files changed

+13630
-2
lines changed

4 files changed

+13630
-2
lines changed

lib/stdlib/test/unicode_util_SUITE.erl

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
nfd/1, nfc/1, nfkd/1, nfkc/1,
3030
whitespace/1,
3131
get/1,
32-
lookup/1,
32+
lookup/1, category/1, is_id_func/1,
3333
count/1]).
3434

3535
-export([debug/0, id/1, bin_split/1, uc_loaded_size/0,
@@ -47,6 +47,8 @@ all() ->
4747
cp, gc,
4848
nfd, nfc, nfkd, nfkc,
4949
whitespace,
50+
category,
51+
is_id_func,
5052
get,
5153
lookup,
5254
count
@@ -91,7 +93,8 @@ casefold(_) ->
9193
[[$s,$s]] = unicode_util:casefold([$ẞ]),
9294
ok.
9395

94-
whitespace(_) ->
96+
whitespace(_Config) ->
97+
%% Pattern whitespace
9598
WS = unicode_util:whitespace(),
9699
WS = lists:filter(fun unicode_util:is_whitespace/1, WS),
97100
false = unicode_util:is_whitespace($A),
@@ -368,6 +371,28 @@ check_category(Id, [{Next,_}|_] = Rest, Es) ->
368371
check_category(_Id, [], Es) ->
369372
Es.
370373

374+
category(_Config) ->
375+
Check = fun(Id) ->
376+
LC = maps:get(category, unicode_util:lookup(Id)),
377+
LC == unicode_util:category(Id)
378+
end,
379+
[] = [Id || Id <- lists:seq(1, 200000), not Check(Id)],
380+
{'EXIT', _} = catch unicode_util:category(-1),
381+
{'EXIT', _} = catch unicode_util:category(5000000),
382+
{'EXIT', _} = catch unicode_util:category(foobar),
383+
ok.
384+
385+
is_id_func(_Config) ->
386+
%% Basic tests more tests in unicode tests
387+
false = unicode_util:is_other_id_start($a),
388+
true = unicode_util:is_other_id_start(6277),
389+
390+
false = unicode_util:is_other_id_continue($a),
391+
true = unicode_util:is_other_id_continue(183),
392+
393+
false = unicode_util:is_letter_not_pattern_syntax(11823),
394+
true = unicode_util:is_letter_not_pattern_syntax($a),
395+
ok.
371396

372397
count(Config) ->
373398
Parent = self(),

0 commit comments

Comments
 (0)