1%%
2%% %CopyrightBegin%
3%%
4%% Copyright Ericsson AB 2020. All Rights Reserved.
5%%
6%% Licensed under the Apache License, Version 2.0 (the "License");
7%% you may not use this file except in compliance with the License.
8%% You may obtain a copy of the License at
9%%
10%%     http://www.apache.org/licenses/LICENSE-2.0
11%%
12%% Unless required by applicable law or agreed to in writing, software
13%% distributed under the License is distributed on an "AS IS" BASIS,
14%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15%% See the License for the specific language governing permissions and
16%% limitations under the License.
17%%
18%% %CopyrightEnd%
19%%
20
21-module(compile_prop).
22-compile([export_all, nowarn_export_all]).
23
24%% This module only supports proper, as we don't have an eqc license to test
25%% with.
26
27-proptest([proper]).
28
29-ifdef(PROPER).
30
31-define(BEAM_TYPES_INTERNAL, true).
32-include_lib("compiler/src/beam_types.hrl").
33
34-include_lib("proper/include/proper.hrl").
35-define(MOD_eqc, proper).
36
37-import(lists, [duplicate/2,foldl/3]).
38
39-define(REPETITIONS, 1000).
40
41compile() ->
42    numtests(?REPETITIONS, compile_1()).
43
44compile_1() ->
45    Opts = [{resize,true}],
46    ?FORALL(Abstr, proper_abstr:module(Opts),
47            ?WHENFAIL(
48               begin
49                   io:format("~ts\n", [[erl_pp:form(F) || F <- Abstr]]),
50                   compile(Abstr, [binary,report_errors])
51               end,
52               case compile(Abstr, [binary]) of
53                   {error, _Es, _Ws} -> false;
54                   _ -> true
55               end)).
56
57compile(Abstr, Opts) ->
58    compile:noenv_forms(Abstr, Opts).
59-endif.
60