aboutsummaryrefslogtreecommitdiffstats
path: root/lib/stdlib/test/string_SUITE.erl
diff options
context:
space:
mode:
Diffstat (limited to 'lib/stdlib/test/string_SUITE.erl')
-rw-r--r--lib/stdlib/test/string_SUITE.erl456
1 files changed, 228 insertions, 228 deletions
diff --git a/lib/stdlib/test/string_SUITE.erl b/lib/stdlib/test/string_SUITE.erl
index 30c46a5bb4..b5d221732e 100644
--- a/lib/stdlib/test/string_SUITE.erl
+++ b/lib/stdlib/test/string_SUITE.erl
@@ -73,115 +73,115 @@ end_per_testcase(_Case, _Config) ->
%%
len(Config) when is_list(Config) ->
- ?line 0 = string:len(""),
- ?line L = tuple_size(list_to_tuple(atom_to_list(?MODULE))),
- ?line L = string:len(atom_to_list(?MODULE)),
+ 0 = string:len(""),
+ L = tuple_size(list_to_tuple(atom_to_list(?MODULE))),
+ L = string:len(atom_to_list(?MODULE)),
%% invalid arg type
- ?line {'EXIT',_} = (catch string:len({})),
+ {'EXIT',_} = (catch string:len({})),
ok.
equal(Config) when is_list(Config) ->
- ?line true = string:equal("", ""),
- ?line false = string:equal("", " "),
- ?line true = string:equal("laban", "laban"),
- ?line false = string:equal("skvimp", "skvump"),
+ true = string:equal("", ""),
+ false = string:equal("", " "),
+ true = string:equal("laban", "laban"),
+ false = string:equal("skvimp", "skvump"),
%% invalid arg type
- ?line true = string:equal(2, 2), % not good, should crash
+ true = string:equal(2, 2), % not good, should crash
ok.
concat(Config) when is_list(Config) ->
- ?line "erlang rules" = string:concat("erlang ", "rules"),
- ?line "" = string:concat("", ""),
- ?line "x" = string:concat("x", ""),
- ?line "y" = string:concat("", "y"),
+ "erlang rules" = string:concat("erlang ", "rules"),
+ "" = string:concat("", ""),
+ "x" = string:concat("x", ""),
+ "y" = string:concat("", "y"),
%% invalid arg type
- ?line {'EXIT',_} = (catch string:concat(hello, please)),
+ {'EXIT',_} = (catch string:concat(hello, please)),
ok.
chr_rchr(Config) when is_list(Config) ->
{_,_,X} = erlang:timestamp(),
- ?line 0 = string:chr("", (X rem (255-32)) + 32),
- ?line 0 = string:rchr("", (X rem (255-32)) + 32),
- ?line 1 = string:chr("x", $x),
- ?line 1 = string:rchr("x", $x),
- ?line 1 = string:chr("xx", $x),
- ?line 2 = string:rchr("xx", $x),
- ?line 3 = string:chr("xyzyx", $z),
- ?line 3 = string:rchr("xyzyx", $z),
+ 0 = string:chr("", (X rem (255-32)) + 32),
+ 0 = string:rchr("", (X rem (255-32)) + 32),
+ 1 = string:chr("x", $x),
+ 1 = string:rchr("x", $x),
+ 1 = string:chr("xx", $x),
+ 2 = string:rchr("xx", $x),
+ 3 = string:chr("xyzyx", $z),
+ 3 = string:rchr("xyzyx", $z),
%% invalid arg type
- ?line {'EXIT',_} = (catch string:chr(hello, $h)),
+ {'EXIT',_} = (catch string:chr(hello, $h)),
%% invalid arg type
- ?line {'EXIT',_} = (catch string:chr("hello", h)),
+ {'EXIT',_} = (catch string:chr("hello", h)),
%% invalid arg type
- ?line {'EXIT',_} = (catch string:rchr(hello, $h)),
+ {'EXIT',_} = (catch string:rchr(hello, $h)),
%% invalid arg type
- ?line {'EXIT',_} = (catch string:rchr("hello", h)),
+ {'EXIT',_} = (catch string:rchr("hello", h)),
ok.
str_rstr(Config) when is_list(Config) ->
{_,_,X} = erlang:timestamp(),
- ?line 0 = string:str("", [(X rem (255-32)) + 32]),
- ?line 0 = string:rstr("", [(X rem (255-32)) + 32]),
- ?line 1 = string:str("x", "x"),
- ?line 1 = string:rstr("x", "x"),
- ?line 0 = string:str("hello", ""),
- ?line 0 = string:rstr("hello", ""),
- ?line 1 = string:str("xxxx", "xx"),
- ?line 3 = string:rstr("xxxx", "xx"),
- ?line 3 = string:str("xy z yx", " z"),
- ?line 3 = string:rstr("xy z yx", " z"),
+ 0 = string:str("", [(X rem (255-32)) + 32]),
+ 0 = string:rstr("", [(X rem (255-32)) + 32]),
+ 1 = string:str("x", "x"),
+ 1 = string:rstr("x", "x"),
+ 0 = string:str("hello", ""),
+ 0 = string:rstr("hello", ""),
+ 1 = string:str("xxxx", "xx"),
+ 3 = string:rstr("xxxx", "xx"),
+ 3 = string:str("xy z yx", " z"),
+ 3 = string:rstr("xy z yx", " z"),
%% invalid arg type
- ?line {'EXIT',_} = (catch string:str(hello, "he")),
+ {'EXIT',_} = (catch string:str(hello, "he")),
%% invalid arg type
- ?line {'EXIT',_} = (catch string:str("hello", he)),
+ {'EXIT',_} = (catch string:str("hello", he)),
%% invalid arg type
- ?line {'EXIT',_} = (catch string:rstr(hello, "he")),
+ {'EXIT',_} = (catch string:rstr(hello, "he")),
%% invalid arg type
- ?line {'EXIT',_} = (catch string:rstr("hello", he)),
+ {'EXIT',_} = (catch string:rstr("hello", he)),
ok.
span_cspan(Config) when is_list(Config) ->
- ?line 0 = string:span("", "1"),
- ?line 0 = string:span("1", ""),
- ?line 0 = string:cspan("", "1"),
- ?line 1 = string:cspan("1", ""),
- ?line 1 = string:span("1 ", "1"),
- ?line 5 = string:span(" 1 ", "12 "),
- ?line 6 = string:span("1231234", "123"),
- ?line 0 = string:cspan("1 ", "1"),
- ?line 1 = string:cspan("3 ", "12 "),
- ?line 6 = string:cspan("1231234", "4"),
+ 0 = string:span("", "1"),
+ 0 = string:span("1", ""),
+ 0 = string:cspan("", "1"),
+ 1 = string:cspan("1", ""),
+ 1 = string:span("1 ", "1"),
+ 5 = string:span(" 1 ", "12 "),
+ 6 = string:span("1231234", "123"),
+ 0 = string:cspan("1 ", "1"),
+ 1 = string:cspan("3 ", "12 "),
+ 6 = string:cspan("1231234", "4"),
%% invalid arg type
- ?line {'EXIT',_} = (catch string:span(1234, "1")),
+ {'EXIT',_} = (catch string:span(1234, "1")),
%% invalid arg type
- ?line {'EXIT',_} = (catch string:span(1234, "1")),
+ {'EXIT',_} = (catch string:span(1234, "1")),
%% invalid arg type
- ?line {'EXIT',_} = (catch string:cspan("1234", 1)),
+ {'EXIT',_} = (catch string:cspan("1234", 1)),
%% invalid arg type
- ?line {'EXIT',_} = (catch string:cspan("1234", 4)),
+ {'EXIT',_} = (catch string:cspan("1234", 4)),
ok.
substr(Config) when is_list(Config) ->
- ?line {'EXIT',_} = (catch string:substr("", 0)),
- ?line [] = string:substr("", 1),
- ?line {'EXIT',_} = (catch string:substr("", 2)),
- ?line [] = string:substr("1", 2),
- ?line {'EXIT',_} = (catch string:substr("", 0, 1)),
- ?line [] = string:substr("", 1, 1),
- ?line [] = string:substr("", 1, 2),
- ?line {'EXIT',_} = (catch string:substr("", 2, 2)),
- ?line "1234" = string:substr("1234", 1),
- ?line "1234" = string:substr("1234", 1, 4),
- ?line "1234" = string:substr("1234", 1, 5),
- ?line "23" = string:substr("1234", 2, 2),
- ?line "4" = string:substr("1234", 4),
- ?line "" = string:substr("1234", 4, 0),
- ?line "4" = string:substr("1234", 4, 1),
- %% invalid arg type
- ?line {'EXIT',_} = (catch string:substr(1234, 1)),
- %% invalid arg type
- ?line {'EXIT',_} = (catch string:substr("1234", "1")),
+ {'EXIT',_} = (catch string:substr("", 0)),
+ [] = string:substr("", 1),
+ {'EXIT',_} = (catch string:substr("", 2)),
+ [] = string:substr("1", 2),
+ {'EXIT',_} = (catch string:substr("", 0, 1)),
+ [] = string:substr("", 1, 1),
+ [] = string:substr("", 1, 2),
+ {'EXIT',_} = (catch string:substr("", 2, 2)),
+ "1234" = string:substr("1234", 1),
+ "1234" = string:substr("1234", 1, 4),
+ "1234" = string:substr("1234", 1, 5),
+ "23" = string:substr("1234", 2, 2),
+ "4" = string:substr("1234", 4),
+ "" = string:substr("1234", 4, 0),
+ "4" = string:substr("1234", 4, 1),
+ %% invalid arg type
+ {'EXIT',_} = (catch string:substr(1234, 1)),
+ %% invalid arg type
+ {'EXIT',_} = (catch string:substr("1234", "1")),
ok.
tokens(Config) when is_list(Config) ->
@@ -219,216 +219,216 @@ replace_sep(C, Seps, New) ->
end.
chars(Config) when is_list(Config) ->
- ?line [] = string:chars($., 0),
- ?line [] = string:chars($., 0, []),
- ?line 10 = length(string:chars(32, 10, [])),
- ?line "aaargh" = string:chars($a, 3, "rgh"),
+ [] = string:chars($., 0),
+ [] = string:chars($., 0, []),
+ 10 = length(string:chars(32, 10, [])),
+ "aaargh" = string:chars($a, 3, "rgh"),
%% invalid arg type
- ?line {'EXIT',_} = (catch string:chars($x, [])),
+ {'EXIT',_} = (catch string:chars($x, [])),
ok.
copies(Config) when is_list(Config) ->
- ?line "" = string:copies("", 10),
- ?line "" = string:copies(".", 0),
- ?line "." = string:copies(".", 1),
- ?line 30 = length(string:copies("123", 10)),
+ "" = string:copies("", 10),
+ "" = string:copies(".", 0),
+ "." = string:copies(".", 1),
+ 30 = length(string:copies("123", 10)),
%% invalid arg type
- ?line {'EXIT',_} = (catch string:copies("hej", -1)),
- ?line {'EXIT',_} = (catch string:copies("hej", 2.0)),
+ {'EXIT',_} = (catch string:copies("hej", -1)),
+ {'EXIT',_} = (catch string:copies("hej", 2.0)),
ok.
words(Config) when is_list(Config) ->
- ?line 1 = string:words(""),
- ?line 1 = string:words("", $,),
- ?line 1 = string:words("hello"),
- ?line 1 = string:words("hello", $,),
- ?line 1 = string:words("...", $.),
- ?line 2 = string:words("2.35", $.),
- ?line 100 = string:words(string:copies(". ", 100)),
+ 1 = string:words(""),
+ 1 = string:words("", $,),
+ 1 = string:words("hello"),
+ 1 = string:words("hello", $,),
+ 1 = string:words("...", $.),
+ 2 = string:words("2.35", $.),
+ 100 = string:words(string:copies(". ", 100)),
%% invalid arg type
- ?line {'EXIT',_} = (catch string:chars(hej, 1)),
+ {'EXIT',_} = (catch string:chars(hej, 1)),
%% invalid arg type
- ?line {'EXIT',_} = (catch string:chars("hej", 1, " ")),
+ {'EXIT',_} = (catch string:chars("hej", 1, " ")),
ok.
strip(Config) when is_list(Config) ->
- ?line "" = string:strip(""),
- ?line "" = string:strip("", both),
- ?line "" = string:strip("", both, $.),
- ?line "hej" = string:strip(" hej "),
- ?line "hej " = string:strip(" hej ", left),
- ?line " hej" = string:strip(" hej ", right),
- ?line " hej " = string:strip(" hej ", right, $.),
- ?line "hej hopp" = string:strip(" hej hopp ", both),
+ "" = string:strip(""),
+ "" = string:strip("", both),
+ "" = string:strip("", both, $.),
+ "hej" = string:strip(" hej "),
+ "hej " = string:strip(" hej ", left),
+ " hej" = string:strip(" hej ", right),
+ " hej " = string:strip(" hej ", right, $.),
+ "hej hopp" = string:strip(" hej hopp ", both),
%% invalid arg type
- ?line {'EXIT',_} = (catch string:strip(hej)),
+ {'EXIT',_} = (catch string:strip(hej)),
%% invalid arg type
- ?line {'EXIT',_} = (catch string:strip(" hej", up)),
+ {'EXIT',_} = (catch string:strip(" hej", up)),
%% invalid arg type
- ?line {'EXIT',_} = (catch string:strip(" hej", left, " ")), % not good
+ {'EXIT',_} = (catch string:strip(" hej", left, " ")), % not good
ok.
sub_word(Config) when is_list(Config) ->
- ?line "" = string:sub_word("", 1),
- ?line "" = string:sub_word("", 1, $,),
- ?line {'EXIT',_} = (catch string:sub_word("1 2 3", 0)),
- ?line "" = string:sub_word("1 2 3", 4),
- ?line "llo th" = string:sub_word("but hello there", 2, $e),
+ "" = string:sub_word("", 1),
+ "" = string:sub_word("", 1, $,),
+ {'EXIT',_} = (catch string:sub_word("1 2 3", 0)),
+ "" = string:sub_word("1 2 3", 4),
+ "llo th" = string:sub_word("but hello there", 2, $e),
%% invalid arg type
- ?line {'EXIT',_} = (catch string:sub_word('hello there', 1)),
+ {'EXIT',_} = (catch string:sub_word('hello there', 1)),
%% invalid arg type
- ?line {'EXIT',_} = (catch string:sub_word("hello there", 1, "e")),
+ {'EXIT',_} = (catch string:sub_word("hello there", 1, "e")),
ok.
left_right(Config) when is_list(Config) ->
- ?line "" = string:left("", 0),
- ?line "" = string:left("hej", 0),
- ?line "" = string:left("hej", 0, $.),
- ?line "" = string:right("", 0),
- ?line "" = string:right("hej", 0),
- ?line "" = string:right("hej", 0, $.),
- ?line "123 " = string:left("123 ", 5),
- ?line " 123" = string:right(" 123", 5),
- ?line "123!!" = string:left("123!", 5, $!),
- ?line "==123" = string:right("=123", 5, $=),
- ?line "1" = string:left("123", 1, $.),
- ?line "3" = string:right("123", 1, $.),
- %% invalid arg type
- ?line {'EXIT',_} = (catch string:left(hello, 5)),
- %% invalid arg type
- ?line {'EXIT',_} = (catch string:right(hello, 5)),
- %% invalid arg type
- ?line {'EXIT',_} = (catch string:left("hello", 5, ".")),
- %% invalid arg type
- ?line {'EXIT',_} = (catch string:right("hello", 5, ".")),
+ "" = string:left("", 0),
+ "" = string:left("hej", 0),
+ "" = string:left("hej", 0, $.),
+ "" = string:right("", 0),
+ "" = string:right("hej", 0),
+ "" = string:right("hej", 0, $.),
+ "123 " = string:left("123 ", 5),
+ " 123" = string:right(" 123", 5),
+ "123!!" = string:left("123!", 5, $!),
+ "==123" = string:right("=123", 5, $=),
+ "1" = string:left("123", 1, $.),
+ "3" = string:right("123", 1, $.),
+ %% invalid arg type
+ {'EXIT',_} = (catch string:left(hello, 5)),
+ %% invalid arg type
+ {'EXIT',_} = (catch string:right(hello, 5)),
+ %% invalid arg type
+ {'EXIT',_} = (catch string:left("hello", 5, ".")),
+ %% invalid arg type
+ {'EXIT',_} = (catch string:right("hello", 5, ".")),
ok.
sub_string(Config) when is_list(Config) ->
- ?line {'EXIT',_} = (catch string:sub_string("", 0)),
- ?line [] = string:sub_string("", 1),
- ?line {'EXIT',_} = (catch string:sub_string("", 2)),
- ?line [] = string:sub_string("1", 2),
- ?line {'EXIT',_} = (catch string:sub_string("", 0, 1)),
- ?line [] = string:sub_string("", 1, 1),
- ?line [] = string:sub_string("", 1, 2),
- ?line {'EXIT',_} = (catch string:sub_string("", 2, 2)),
- ?line "1234" = string:sub_string("1234", 1),
- ?line "1234" = string:sub_string("1234", 1, 4),
- ?line "1234" = string:sub_string("1234", 1, 5),
- ?line "23" = string:sub_string("1234", 2, 3),
- ?line "4" = string:sub_string("1234", 4),
- ?line "4" = string:sub_string("1234", 4, 4),
- ?line "4" = string:sub_string("1234", 4, 5),
- %% invalid arg type
- ?line {'EXIT',_} = (catch string:sub_string(1234, 1)),
- %% invalid arg type
- ?line {'EXIT',_} = (catch string:sub_string("1234", "1")),
+ {'EXIT',_} = (catch string:sub_string("", 0)),
+ [] = string:sub_string("", 1),
+ {'EXIT',_} = (catch string:sub_string("", 2)),
+ [] = string:sub_string("1", 2),
+ {'EXIT',_} = (catch string:sub_string("", 0, 1)),
+ [] = string:sub_string("", 1, 1),
+ [] = string:sub_string("", 1, 2),
+ {'EXIT',_} = (catch string:sub_string("", 2, 2)),
+ "1234" = string:sub_string("1234", 1),
+ "1234" = string:sub_string("1234", 1, 4),
+ "1234" = string:sub_string("1234", 1, 5),
+ "23" = string:sub_string("1234", 2, 3),
+ "4" = string:sub_string("1234", 4),
+ "4" = string:sub_string("1234", 4, 4),
+ "4" = string:sub_string("1234", 4, 5),
+ %% invalid arg type
+ {'EXIT',_} = (catch string:sub_string(1234, 1)),
+ %% invalid arg type
+ {'EXIT',_} = (catch string:sub_string("1234", "1")),
ok.
centre(Config) when is_list(Config) ->
- ?line "" = string:centre("", 0),
- ?line "" = string:centre("1", 0),
- ?line "" = string:centre("", 0, $-),
- ?line "" = string:centre("1", 0, $-),
- ?line "gd" = string:centre("agda", 2),
- ?line "agda " = string:centre("agda", 5),
- ?line " agda " = string:centre("agda", 6),
- ?line "agda." = string:centre("agda", 5, $.),
- ?line "--agda--" = string:centre("agda", 8, $-),
- ?line "agda" = string:centre("agda", 4),
- %% invalid arg type
- ?line {'EXIT',_} = (catch string:centre(hello, 10)),
+ "" = string:centre("", 0),
+ "" = string:centre("1", 0),
+ "" = string:centre("", 0, $-),
+ "" = string:centre("1", 0, $-),
+ "gd" = string:centre("agda", 2),
+ "agda " = string:centre("agda", 5),
+ " agda " = string:centre("agda", 6),
+ "agda." = string:centre("agda", 5, $.),
+ "--agda--" = string:centre("agda", 8, $-),
+ "agda" = string:centre("agda", 4),
+ %% invalid arg type
+ {'EXIT',_} = (catch string:centre(hello, 10)),
ok.
to_integer(Config) when is_list(Config) ->
- ?line {1,""} = test_to_integer("1"),
- ?line {1,""} = test_to_integer("+1"),
- ?line {-1,""} = test_to_integer("-1"),
- ?line {1,"="} = test_to_integer("1="),
- ?line {7,"F"} = test_to_integer("7F"),
- ?line {709,""} = test_to_integer("709"),
- ?line {709,"*2"} = test_to_integer("709*2"),
- ?line {0,"xAB"} = test_to_integer("0xAB"),
- ?line {16,"#FF"} = test_to_integer("16#FF"),
- ?line {error,no_integer} = test_to_integer(""),
- ?line {error,no_integer} = test_to_integer("!1"),
- ?line {error,no_integer} = test_to_integer("F1"),
- ?line {error,not_a_list} = test_to_integer('23'),
- ?line {3,[[]]} = test_to_integer([$3,[]]),
- ?line {3,[hello]} = test_to_integer([$3,hello]),
+ {1,""} = test_to_integer("1"),
+ {1,""} = test_to_integer("+1"),
+ {-1,""} = test_to_integer("-1"),
+ {1,"="} = test_to_integer("1="),
+ {7,"F"} = test_to_integer("7F"),
+ {709,""} = test_to_integer("709"),
+ {709,"*2"} = test_to_integer("709*2"),
+ {0,"xAB"} = test_to_integer("0xAB"),
+ {16,"#FF"} = test_to_integer("16#FF"),
+ {error,no_integer} = test_to_integer(""),
+ {error,no_integer} = test_to_integer("!1"),
+ {error,no_integer} = test_to_integer("F1"),
+ {error,not_a_list} = test_to_integer('23'),
+ {3,[[]]} = test_to_integer([$3,[]]),
+ {3,[hello]} = test_to_integer([$3,hello]),
ok.
test_to_integer(Str) ->
io:format("Checking ~p~n", [Str]),
case string:to_integer(Str) of
{error,_Reason} = Bad ->
- ?line {'EXIT',_} = (catch list_to_integer(Str)),
+ {'EXIT',_} = (catch list_to_integer(Str)),
Bad;
{F,_Rest} = Res ->
- ?line _ = integer_to_list(F),
+ _ = integer_to_list(F),
Res
end.
to_float(Config) when is_list(Config) ->
- ?line {1.2,""} = test_to_float("1.2"),
- ?line {1.2,""} = test_to_float("1,2"),
- ?line {120.0,""} = test_to_float("1.2e2"),
- ?line {120.0,""} = test_to_float("+1,2e2"),
- ?line {-120.0,""} = test_to_float("-1.2e2"),
- ?line {-120.0,""} = test_to_float("-1,2e+2"),
- ?line {-1.2e-2,""} = test_to_float("-1.2e-2"),
- ?line {1.2,"="} = test_to_float("1.2="),
- ?line {7.9,"e"} = test_to_float("7.9e"),
- ?line {7.9,"ee"} = test_to_float("7.9ee"),
- ?line {7.9,"e+"} = test_to_float("7.9e+"),
- ?line {7.9,"e-"} = test_to_float("7.9e-"),
- ?line {7.9,"e++"} = test_to_float("7.9e++"),
- ?line {7.9,"e--"} = test_to_float("7.9e--"),
- ?line {7.9,"e+e"} = test_to_float("7.9e+e"),
- ?line {7.9,"e-e"} = test_to_float("7.9e-e"),
- ?line {7.9,"e+."} = test_to_float("7.9e+."),
- ?line {7.9,"e-."} = test_to_float("7.9e-."),
- ?line {7.9,"e+,"} = test_to_float("7.9e+,"),
- ?line {7.9,"e-,"} = test_to_float("7.9e-,"),
- ?line {error,no_float} = test_to_float(""),
- ?line {error,no_float} = test_to_float("e1,0"),
- ?line {error,no_float} = test_to_float("1;0"),
- ?line {error,no_float} = test_to_float("1"),
- ?line {error,no_float} = test_to_float("1e"),
- ?line {error,no_float} = test_to_float("2."),
- ?line {error,not_a_list} = test_to_float('2.3'),
- ?line {2.3,[[]]} = test_to_float([$2,$.,$3,[]]),
- ?line {2.3,[hello]} = test_to_float([$2,$.,$3,hello]),
+ {1.2,""} = test_to_float("1.2"),
+ {1.2,""} = test_to_float("1,2"),
+ {120.0,""} = test_to_float("1.2e2"),
+ {120.0,""} = test_to_float("+1,2e2"),
+ {-120.0,""} = test_to_float("-1.2e2"),
+ {-120.0,""} = test_to_float("-1,2e+2"),
+ {-1.2e-2,""} = test_to_float("-1.2e-2"),
+ {1.2,"="} = test_to_float("1.2="),
+ {7.9,"e"} = test_to_float("7.9e"),
+ {7.9,"ee"} = test_to_float("7.9ee"),
+ {7.9,"e+"} = test_to_float("7.9e+"),
+ {7.9,"e-"} = test_to_float("7.9e-"),
+ {7.9,"e++"} = test_to_float("7.9e++"),
+ {7.9,"e--"} = test_to_float("7.9e--"),
+ {7.9,"e+e"} = test_to_float("7.9e+e"),
+ {7.9,"e-e"} = test_to_float("7.9e-e"),
+ {7.9,"e+."} = test_to_float("7.9e+."),
+ {7.9,"e-."} = test_to_float("7.9e-."),
+ {7.9,"e+,"} = test_to_float("7.9e+,"),
+ {7.9,"e-,"} = test_to_float("7.9e-,"),
+ {error,no_float} = test_to_float(""),
+ {error,no_float} = test_to_float("e1,0"),
+ {error,no_float} = test_to_float("1;0"),
+ {error,no_float} = test_to_float("1"),
+ {error,no_float} = test_to_float("1e"),
+ {error,no_float} = test_to_float("2."),
+ {error,not_a_list} = test_to_float('2.3'),
+ {2.3,[[]]} = test_to_float([$2,$.,$3,[]]),
+ {2.3,[hello]} = test_to_float([$2,$.,$3,hello]),
ok.
test_to_float(Str) ->
io:format("Checking ~p~n", [Str]),
case string:to_float(Str) of
{error,_Reason} = Bad ->
- ?line {'EXIT',_} = (catch list_to_float(Str)),
+ {'EXIT',_} = (catch list_to_float(Str)),
Bad;
{F,_Rest} = Res ->
- ?line _ = float_to_list(F),
+ _ = float_to_list(F),
Res
end.
-
+
to_upper_to_lower(Config) when is_list(Config) ->
- ?line "1234ABCDEFÅÄÖ=" = string:to_upper("1234abcdefåäö="),
- ?line "éèíúùòóåäöabc()" = string:to_lower("ÉÈÍÚÙÒÓÅÄÖabc()"),
- ?line All = lists:seq(0, 255),
+ "1234ABCDEFÅÄÖ=" = string:to_upper("1234abcdefåäö="),
+ "éèíúùòóåäöabc()" = string:to_lower("ÉÈÍÚÙÒÓÅÄÖabc()"),
+ All = lists:seq(0, 255),
- ?line UC = string:to_upper(All),
- ?line 256 = length(UC),
- ?line all_upper_latin1(UC, 0),
+ UC = string:to_upper(All),
+ 256 = length(UC),
+ all_upper_latin1(UC, 0),
- ?line LC = string:to_lower(All),
- ?line all_lower_latin1(LC, 0),
+ LC = string:to_lower(All),
+ all_lower_latin1(LC, 0),
- ?line LC = string:to_lower(string:to_upper(LC)),
- ?line LC = string:to_lower(string:to_upper(UC)),
- ?line UC = string:to_upper(string:to_lower(LC)),
- ?line UC = string:to_upper(string:to_lower(UC)),
+ LC = string:to_lower(string:to_upper(LC)),
+ LC = string:to_lower(string:to_upper(UC)),
+ UC = string:to_upper(string:to_lower(LC)),
+ UC = string:to_upper(string:to_lower(UC)),
ok.
all_upper_latin1([C|T], C) when 0 =< C, C < $a;
@@ -456,10 +456,10 @@ all_lower_latin1([H|T], C) when $A =< C, C =< $Z;
all_lower_latin1([], 256) -> ok.
join(Config) when is_list(Config) ->
- ?line "erlang rules" = string:join(["erlang", "rules"], " "),
- ?line "a,-,b,-,c" = string:join(["a", "b", "c"], ",-,"),
- ?line "1234" = string:join(["1", "2", "3", "4"], ""),
- ?line [] = string:join([], ""), % OTP-7231
+ "erlang rules" = string:join(["erlang", "rules"], " "),
+ "a,-,b,-,c" = string:join(["a", "b", "c"], ",-,"),
+ "1234" = string:join(["1", "2", "3", "4"], ""),
+ [] = string:join([], ""), % OTP-7231
%% invalid arg type
- ?line {'EXIT',_} = (catch string:join([apa], "")),
+ {'EXIT',_} = (catch string:join([apa], "")),
ok.