20
20
21
21
-export ([all /1 ,init_per_testcase /2 ,fin_per_testcase /2 ,
22
22
tobias /1 ,empty_string /1 ,md5 /1 ,silly_coverage /1 ,
23
- confused_literals /1 ,integer_encoding /1 ]).
23
+ confused_literals /1 ,integer_encoding /1 , override_bif / 1 ]).
24
24
25
25
-include (" test_server.hrl" ).
26
26
27
+ % % For the override_bif testcase.
28
+ % % NB, no other testcases in this testsuite can use these without erlang:prefix!
29
+ -compile ({no_auto_import ,[abs / 1 ]}).
30
+ -compile ({no_auto_import ,[binary_part / 3 ]}).
31
+ -compile ({no_auto_import ,[binary_part / 2 ]}).
32
+ -import (test_lib ,[binary_part /2 ]).
33
+
34
+ % % This should do no harm (except for fun byte_size/1 which does not, by design, work with import
35
+ -compile ({no_auto_import ,[byte_size / 1 ]}).
36
+ -import (erlang ,[byte_size /1 ]).
37
+
38
+
39
+
27
40
% % Include an opaque declaration to cover the stripping of
28
41
% % opaque types from attributes in v3_kernel.
29
42
-opaque misc_SUITE_test_cases () :: [atom ()].
@@ -42,7 +55,39 @@ fin_per_testcase(Case, Config) when is_atom(Case), is_list(Config) ->
42
55
all (suite ) ->
43
56
test_lib :recompile (? MODULE ),
44
57
[tobias ,empty_string ,md5 ,silly_coverage ,confused_literals ,
45
- integer_encoding ].
58
+ integer_encoding , override_bif ].
59
+
60
+
61
+ % %
62
+ % % Functions that override new and old bif's
63
+ % %
64
+ abs (_N ) ->
65
+ dummy_abs .
66
+
67
+ binary_part (_ ,_ ,_ ) ->
68
+ dummy_bp .
69
+
70
+ % Make sure that auto-imported BIF's are overridden correctly
71
+
72
+ override_bif (suite ) ->
73
+ [];
74
+ override_bif (doc ) ->
75
+ [" Test dat local functions and imports override auto-imported BIFs." ];
76
+ override_bif (Config ) when is_list (Config ) ->
77
+ ? line dummy_abs = abs (1 ),
78
+ ? line dummy_bp = binary_part (<<" hello" >>,1 ,1 ),
79
+ ? line dummy = binary_part (<<" hello" >>,{1 ,1 }),
80
+ ? line 1 = erlang :abs (1 ),
81
+ ? line <<" e" >> = erlang :binary_part (<<" hello" >>,1 ,1 ),
82
+ ? line <<" e" >> = erlang :binary_part (<<" hello" >>,{1 ,1 }),
83
+ F = fun (X ) when byte_size (X ) =:= 4 ->
84
+ four ;
85
+ (X ) ->
86
+ byte_size (X )
87
+ end ,
88
+ ? line four = F (<<1 ,2 ,3 ,4 >>),
89
+ ? line 5 = F (<<1 ,2 ,3 ,4 ,5 >>),
90
+ ok .
46
91
47
92
% % A bug reported by Tobias Lindahl for a development version of R11B.
48
93
0 commit comments