diff options
author | Sverker Eriksson <[email protected]> | 2017-03-08 14:46:24 +0100 |
---|---|---|
committer | Sverker Eriksson <[email protected]> | 2017-03-08 18:07:09 +0100 |
commit | 32d13d59910a384ad09682cafc83c7300c96c694 (patch) | |
tree | 1f5bfca2565243210b16a6de2bdc3ae66cbff8bb /lib/erl_interface/test | |
parent | 65b04e233e09e3cc2e0fda3c28e155b95c5a4baf (diff) | |
download | otp-32d13d59910a384ad09682cafc83c7300c96c694.tar.gz otp-32d13d59910a384ad09682cafc83c7300c96c694.tar.bz2 otp-32d13d59910a384ad09682cafc83c7300c96c694.zip |
erl_interface: Do not generate atoms on old latin1 ext format
Solved by letting ei_encode_atom_as ignore 'to_enc' argument
and always encode in UTF8 format.
Diffstat (limited to 'lib/erl_interface/test')
-rw-r--r-- | lib/erl_interface/test/ei_decode_SUITE.erl | 25 | ||||
-rw-r--r-- | lib/erl_interface/test/ei_decode_SUITE_data/ei_decode_test.c | 18 | ||||
-rw-r--r-- | lib/erl_interface/test/ei_decode_encode_SUITE.erl | 1 | ||||
-rw-r--r-- | lib/erl_interface/test/ei_encode_SUITE.erl | 36 | ||||
-rw-r--r-- | lib/erl_interface/test/erl_ext_SUITE_data/ext_test.c | 10 |
5 files changed, 50 insertions, 40 deletions
diff --git a/lib/erl_interface/test/ei_decode_SUITE.erl b/lib/erl_interface/test/ei_decode_SUITE.erl index 10e90685c8..8612450692 100644 --- a/lib/erl_interface/test/ei_decode_SUITE.erl +++ b/lib/erl_interface/test/ei_decode_SUITE.erl @@ -179,7 +179,8 @@ test_ei_decode_misc(Config) when is_list(Config) -> send_term_as_binary(P,foo), send_term_as_binary(P,''), - send_term_as_binary(P,'ÅÄÖåäö'), + %%send_term_as_binary(P,'ÅÄÖåäö'), + send_latin1_atom_as_binary(P, "ÅÄÖåäö"), send_term_as_binary(P,"foo"), send_term_as_binary(P,""), @@ -200,18 +201,19 @@ test_ei_decode_misc(Config) when is_list(Config) -> test_ei_decode_utf8_atom(Config) -> P = runner:start(?test_ei_decode_utf8_atom), - send_utf8_atom_as_binary(P,"å"), - send_utf8_atom_as_binary(P,"ä"), - send_term_as_binary(P,'ö'), - send_term_as_binary(P,'õ'), + send_latin1_atom_as_binary(P,"å"), + send_latin1_atom_as_binary(P,"ä"), + send_latin1_atom_as_binary(P,"ö"), + send_latin1_atom_as_binary(P,"õ"), send_utf8_atom_as_binary(P,[1758]), send_utf8_atom_as_binary(P,[1758,1758]), send_utf8_atom_as_binary(P,[1758,1758,1758]), send_utf8_atom_as_binary(P,[1758,1758,1758,1758]), - send_utf8_atom_as_binary(P,"a"), - send_utf8_atom_as_binary(P,"b"), + send_latin1_atom_as_binary(P,"a"), + send_latin1_atom_as_binary(P,"b"), + send_term_as_binary(P,'c'), send_term_as_binary(P,'d'), @@ -230,6 +232,9 @@ send_raw(Port, Bin) when is_port(Port) -> send_utf8_atom_as_binary(Port, String) -> Port ! {self(), {command, term_to_binary(uc_atup(String))}}. +send_latin1_atom_as_binary(Port, String) -> + Port ! {self(), {command, encode_latin1_atom(String)}}. + send_integers(P) -> send_term_as_binary(P,0), % SMALL_INTEGER_EXT smallest send_term_as_binary(P,255), % SMALL_INTEGER_EXT largest @@ -304,6 +309,12 @@ send_integers2(P) -> send_term_as_binary(P, []), % illegal type ok. +encode_latin1_atom(String) -> + Len = length(String), + %% Use ATOM_EXT (not SMALL_*) to simulate old term_to_binary + TagLen = [$d, Len bsr 8, Len band 16#ff], + list_to_binary([131, TagLen, String]). + uc_atup(ATxt) -> string_to_atom(ATxt). diff --git a/lib/erl_interface/test/ei_decode_SUITE_data/ei_decode_test.c b/lib/erl_interface/test/ei_decode_SUITE_data/ei_decode_test.c index cfe9083065..649dc9a677 100644 --- a/lib/erl_interface/test/ei_decode_SUITE_data/ei_decode_test.c +++ b/lib/erl_interface/test/ei_decode_SUITE_data/ei_decode_test.c @@ -102,7 +102,7 @@ int ei_decode_my_string(const char *buf, int *index, char *to, } \ \ if (size1 != SIZE) { \ - fail("size of encoded data is incorrect"); \ + fail1("size of encoded data (%d) is incorrect", size1); \ return; \ } \ } \ @@ -614,11 +614,11 @@ TESTCASE(test_ei_decode_misc) EI_DECODE_2(decode_double, 9, double, -1.0); EI_DECODE_2(decode_double, 9, double, 1.0); - EI_DECODE_2(decode_boolean, 8, int, 0); - EI_DECODE_2(decode_boolean, 7, int, 1); + EI_DECODE_2(decode_boolean, 7, int, 0); + EI_DECODE_2(decode_boolean, 6, int, 1); - EI_DECODE_STRING(decode_my_atom, 6, "foo"); - EI_DECODE_STRING(decode_my_atom, 3, ""); + EI_DECODE_STRING(decode_my_atom, 5, "foo"); + EI_DECODE_STRING(decode_my_atom, 2, ""); EI_DECODE_STRING(decode_my_atom, 9, "������"); EI_DECODE_STRING(decode_my_string, 6, "foo"); @@ -665,10 +665,10 @@ TESTCASE(test_ei_decode_utf8_atom) P99({ERLANG_ANY,ERLANG_LATIN1,ERLANG_ASCII})); EI_DECODE_STRING_4(decode_my_atom_as, 4, "b", P99({ERLANG_UTF8,ERLANG_LATIN1,ERLANG_ASCII})); - EI_DECODE_STRING_4(decode_my_atom_as, 4, "c", - P99({ERLANG_LATIN1,ERLANG_LATIN1,ERLANG_ASCII})); - EI_DECODE_STRING_4(decode_my_atom_as, 4, "d", - P99({ERLANG_ASCII,ERLANG_LATIN1,ERLANG_ASCII})); + EI_DECODE_STRING_4(decode_my_atom_as, 3, "c", + P99({ERLANG_LATIN1,ERLANG_UTF8,ERLANG_ASCII})); + EI_DECODE_STRING_4(decode_my_atom_as, 3, "d", + P99({ERLANG_ASCII,ERLANG_UTF8,ERLANG_ASCII})); report(1); } diff --git a/lib/erl_interface/test/ei_decode_encode_SUITE.erl b/lib/erl_interface/test/ei_decode_encode_SUITE.erl index 570a91e2da..108a1f5142 100644 --- a/lib/erl_interface/test/ei_decode_encode_SUITE.erl +++ b/lib/erl_interface/test/ei_decode_encode_SUITE.erl @@ -170,7 +170,6 @@ get_binary(P) -> -define(VERSION_MAGIC, 131). --define(ATOM_EXT, 100). -define(REFERENCE_EXT, 101). -define(PORT_EXT, 102). -define(PID_EXT, 103). diff --git a/lib/erl_interface/test/ei_encode_SUITE.erl b/lib/erl_interface/test/ei_encode_SUITE.erl index ac6ec9cf4e..43484a1319 100644 --- a/lib/erl_interface/test/ei_encode_SUITE.erl +++ b/lib/erl_interface/test/ei_encode_SUITE.erl @@ -184,17 +184,17 @@ test_ei_encode_misc(Config) when is_list(Config) -> {<<70,_:8/binary>>,Fp1} = get_buf_and_term(P), true = match_float(Fp1, 1.0), - {<<100,0,5,"false">>,false} = get_buf_and_term(P), - {<<100,0,4,"true">> ,true} = get_buf_and_term(P), - {<<100,0,4,"true">> ,true} = get_buf_and_term(P), - {<<100,0,4,"true">> ,true} = get_buf_and_term(P), - - {<<100,0,3,"foo">>,foo} = get_buf_and_term(P), - {<<100,0,3,"foo">>,foo} = get_buf_and_term(P), - {<<100,0,0,"">>,''} = get_buf_and_term(P), - {<<100,0,0,"">>,''} = get_buf_and_term(P), - {<<100,0,6,"ÅÄÖåäö">>,'ÅÄÖåäö'} = get_buf_and_term(P), - {<<100,0,6,"ÅÄÖåäö">>,'ÅÄÖåäö'} = get_buf_and_term(P), + {<<$w,5,"false">>,false} = get_buf_and_term(P), + {<<$w,4,"true">> ,true} = get_buf_and_term(P), + {<<$w,4,"true">> ,true} = get_buf_and_term(P), + {<<$w,4,"true">> ,true} = get_buf_and_term(P), + + {<<$w,3,"foo">>,foo} = get_buf_and_term(P), + {<<$w,3,"foo">>,foo} = get_buf_and_term(P), + {<<$w,0,"">>,''} = get_buf_and_term(P), + {<<$w,0,"">>,''} = get_buf_and_term(P), + {<<$w,12,"ÅÄÖåäö"/utf8>>,'ÅÄÖåäö'} = get_buf_and_term(P), + {<<$w,12,"ÅÄÖåäö"/utf8>>,'ÅÄÖåäö'} = get_buf_and_term(P), {<<107,0,3,"foo">>,"foo"} = get_buf_and_term(P), {<<107,0,3,"foo">>,"foo"} = get_buf_and_term(P), @@ -239,12 +239,12 @@ test_ei_encode_utf8_atom(Config) -> P = runner:start(?test_ei_encode_utf8_atom), {<<119,2,195,133>>,'Å'} = get_buf_and_term(P), - {<<100,0,1,197>>,'Å'} = get_buf_and_term(P), - {<<100,0,1,197>>,'Å'} = get_buf_and_term(P), + {<<119,2,195,133>>,'Å'} = get_buf_and_term(P), + {<<119,2,195,133>>,'Å'} = get_buf_and_term(P), {<<119,2,195,133>>,'Å'} = get_buf_and_term(P), {<<119,1,$A>>,'A'} = get_buf_and_term(P), - {<<100,0,1,$A>>,'A'} = get_buf_and_term(P), + {<<119,1,$A>>,'A'} = get_buf_and_term(P), runner:recv_eot(P), ok. @@ -254,13 +254,13 @@ test_ei_encode_utf8_atom_len(Config) -> P = runner:start(?test_ei_encode_utf8_atom_len), {<<119,2,195,133>>,'Å'} = get_buf_and_term(P), - {<<100,0,2,197,196>>,'ÅÄ'} = get_buf_and_term(P), - {<<100,0,1,197>>,'Å'} = get_buf_and_term(P), + {<<119,4,195,133,195,132>>,'ÅÄ'} = get_buf_and_term(P), + {<<119,2,195,133>>,'Å'} = get_buf_and_term(P), {<<119,4,195,133,195,132>>,'ÅÄ'} = get_buf_and_term(P), {<<119,1,$A>>,'A'} = get_buf_and_term(P), - {<<100,0,2,$A,$B>>,'AB'} = get_buf_and_term(P), - {<<100,0,255,_:(255*8)>>,_} = get_buf_and_term(P), + {<<119,2,$A,$B>>,'AB'} = get_buf_and_term(P), + {<<119,255,_:(255*8)>>,_} = get_buf_and_term(P), runner:recv_eot(P), ok. diff --git a/lib/erl_interface/test/erl_ext_SUITE_data/ext_test.c b/lib/erl_interface/test/erl_ext_SUITE_data/ext_test.c index 36cf086ed2..afac5485e8 100644 --- a/lib/erl_interface/test/erl_ext_SUITE_data/ext_test.c +++ b/lib/erl_interface/test/erl_ext_SUITE_data/ext_test.c @@ -407,7 +407,7 @@ test_compare_ext(char *test_desc, } -#define ATOM_EXT (100) +#define SMALL_ATOM_UTF8_EXT (119) #define REFERENCE_EXT (101) #define PORT_EXT (102) #define PID_EXT (103) @@ -429,13 +429,13 @@ write_atom(unsigned char *buf, char *atom) len = 0; while(atom[len]) { - buf[len + 3] = atom[len]; + buf[len + 2] = atom[len]; len++; } - buf[0] = ATOM_EXT; - PUT_UINT16(&buf[1], len); + buf[0] = SMALL_ATOM_UTF8_EXT; + buf[1] = len; - return buf + 3 + len; + return buf + 2 + len; } static unsigned char * |