From e1ddac15900e6a68fd9597e8e93fa135bc63abbd Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Wed, 10 Jul 2019 09:07:04 +0200 Subject: [PATCH] utf8: remove unused UTF8_CHAR_LEN macro and add a simple utf8 test --- compiler/main.v | 3 +-- compiler/parser.v | 2 +- vlib/builtin/utf8_test.v | 5 +++++ 3 files changed, 7 insertions(+), 3 deletions(-) create mode 100644 vlib/builtin/utf8_test.v diff --git a/compiler/main.v b/compiler/main.v index 27131df7d9..714adf3866 100644 --- a/compiler/main.v +++ b/compiler/main.v @@ -229,13 +229,12 @@ typedef map map_string; #define false 0 #endif -//============================== HELPER C.MACROS =============================*/ +//============================== HELPER C MACROS =============================*/ #define _PUSH(arr, val, tmp, tmp_typ) {tmp_typ tmp = (val); array__push(arr, &tmp);} #define _PUSH_MANY(arr, val, tmp, tmp_typ) {tmp_typ tmp = (val); array__push_many(arr, tmp.data, tmp.len);} #define _IN(typ, val, arr) array_##typ##_contains(arr, val) #define ALLOC_INIT(type, ...) (type *)memdup((type[]){ __VA_ARGS__ }, sizeof(type)) -#define UTF8_.chartoken_.leN( byte ) (( 0xE5000000 >> (( byte >> 3 ) & 0x1e )) & 3 ) + 1 //================================== GLOBALS =================================*/ //int V_ZERO = 0; diff --git a/compiler/parser.v b/compiler/parser.v index 1b596ed8e0..c9f3bd667f 100644 --- a/compiler/parser.v +++ b/compiler/parser.v @@ -3017,7 +3017,7 @@ fn (p mut Parser) assert_statement() { filename := p.file_path p.genln(';\n if (!$tmp) { - puts("\\x1B[31mFAI.leD: $p.cur_fn.name() in $filename:$p.scanner.line_nr\\x1B[0m"); + puts("\\x1B[31mFAILED: $p.cur_fn.name() in $filename:$p.scanner.line_nr\\x1B[0m"); g_test_ok = 0 ; // TODO // Maybe print all vars in a test function if it fails? diff --git a/vlib/builtin/utf8_test.v b/vlib/builtin/utf8_test.v new file mode 100644 index 0000000000..356332330c --- /dev/null +++ b/vlib/builtin/utf8_test.v @@ -0,0 +1,5 @@ +fn test_utf8_char_len() { + assert utf8_char_len(`a`) == 1 + s := 'п' + assert utf8_char_len(s[0]) == 2 +}