aboutsummaryrefslogtreecommitdiffstats
path: root/lib/compiler
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2012-01-04 15:30:51 +0100
committerBjörn Gustavsson <[email protected]>2012-01-04 16:14:19 +0100
commiteea9dc51efcaceb1379caa288443aebb274ba87b (patch)
tree2110ebbd939a6c21f7ecc8de84c4a75c4b001286 /lib/compiler
parentd990fedd8f817373066debe6ecea343622b1a78e (diff)
downloadotp-eea9dc51efcaceb1379caa288443aebb274ba87b.tar.gz
otp-eea9dc51efcaceb1379caa288443aebb274ba87b.tar.bz2
otp-eea9dc51efcaceb1379caa288443aebb274ba87b.zip
core_SUITE: Cover v3_kernel:build_match/2
Diffstat (limited to 'lib/compiler')
-rw-r--r--lib/compiler/test/core_SUITE.erl28
-rw-r--r--lib/compiler/test/core_SUITE_data/unsafe_case.core25
2 files changed, 37 insertions, 16 deletions
diff --git a/lib/compiler/test/core_SUITE.erl b/lib/compiler/test/core_SUITE.erl
index 37d220518e..0a52dcdc4a 100644
--- a/lib/compiler/test/core_SUITE.erl
+++ b/lib/compiler/test/core_SUITE.erl
@@ -22,7 +22,8 @@
init_per_group/2,end_per_group/2,
init_per_testcase/2,end_per_testcase/2,
dehydrated_itracer/1,nested_tries/1,
- make_effect_seq/1,eval_is_boolean/1]).
+ make_effect_seq/1,eval_is_boolean/1,
+ unsafe_case/1]).
-include_lib("test_server/include/test_server.hrl").
@@ -43,7 +44,7 @@ suite() -> [{ct_hooks,[ts_install_cth]}].
all() ->
test_lib:recompile(?MODULE),
[dehydrated_itracer,nested_tries,make_effect_seq,
- eval_is_boolean].
+ eval_is_boolean,unsafe_case].
groups() ->
[].
@@ -65,19 +66,14 @@ end_per_group(_GroupName, Config) ->
?comp(nested_tries).
?comp(make_effect_seq).
?comp(eval_is_boolean).
+?comp(unsafe_case).
try_it(Mod, Conf) ->
- ?line Src = filename:join(?config(data_dir, Conf), atom_to_list(Mod)),
- ?line Out = ?config(priv_dir,Conf),
- ?line io:format("Compiling: ~s\n", [Src]),
- ?line CompRc0 = compile:file(Src, [from_core,{outdir,Out},report,time]),
- ?line io:format("Result: ~p\n",[CompRc0]),
- ?line {ok,Mod} = CompRc0,
-
- ?line {module,Mod} = code:load_abs(filename:join(Out, Mod)),
- ?line ok = Mod:Mod(),
- ok.
-
-
-
-
+ Src = filename:join(?config(data_dir, Conf), atom_to_list(Mod)),
+ compile_and_load(Src, []),
+ compile_and_load(Src, [no_copt]).
+
+compile_and_load(Src, Opts) ->
+ {ok,Mod,Bin} = compile:file(Src, [from_core,report,time,binary|Opts]),
+ {module,Mod} = code:load_binary(Mod, Mod, Bin),
+ ok = Mod:Mod().
diff --git a/lib/compiler/test/core_SUITE_data/unsafe_case.core b/lib/compiler/test/core_SUITE_data/unsafe_case.core
new file mode 100644
index 0000000000..84cb2c310a
--- /dev/null
+++ b/lib/compiler/test/core_SUITE_data/unsafe_case.core
@@ -0,0 +1,25 @@
+module 'unsafe_case' ['unsafe_case'/0]
+ attributes []
+'unsafe_case'/0 =
+ fun () ->
+ case apply 't'/1
+ (42) of
+ <{'ok',42}> when 'true' ->
+ 'ok'
+ ( <_cor0> when 'true' ->
+ primop 'match_fail'
+ ({'badmatch',_cor0})
+ -| ['compiler_generated'] )
+ end
+'t'/1 =
+ fun (_cor0) ->
+ case _cor0 of
+ <X>
+ when call 'erlang':'>'
+ (_cor0,
+ 0) ->
+ {'ok',X}
+ %% The default case is intentionally missing
+ %% to cover v3_kernel:build_match/2.
+ end
+end