aboutsummaryrefslogtreecommitdiffstats
path: root/lib/compiler/test
diff options
context:
space:
mode:
authorJohn Högberg <[email protected]>2019-06-28 14:43:56 +0200
committerJohn Högberg <[email protected]>2019-07-05 09:45:09 +0200
commit2b5b3f1988d8ac46ba4c3de2c050af86511c7a18 (patch)
tree5ff23cc6afacaf4c87a20fe15523a6946f136e2f /lib/compiler/test
parent0fc33edda1bac5dbc17a81b531d024681a481674 (diff)
downloadotp-2b5b3f1988d8ac46ba4c3de2c050af86511c7a18.tar.gz
otp-2b5b3f1988d8ac46ba4c3de2c050af86511c7a18.tar.bz2
otp-2b5b3f1988d8ac46ba4c3de2c050af86511c7a18.zip
beam_types: Fix an integer consistency in meet/2
The test was brainfart; integers that don't overlap *AT ALL* should never meet. It's okay to meet as long as they overlap to some degree.
Diffstat (limited to 'lib/compiler/test')
-rw-r--r--lib/compiler/test/beam_types_SUITE.erl31
1 files changed, 25 insertions, 6 deletions
diff --git a/lib/compiler/test/beam_types_SUITE.erl b/lib/compiler/test/beam_types_SUITE.erl
index 1b6397301b..8e71a716cd 100644
--- a/lib/compiler/test/beam_types_SUITE.erl
+++ b/lib/compiler/test/beam_types_SUITE.erl
@@ -32,7 +32,8 @@
identity/1]).
-export([binary_absorption/1,
- integer_absorption/1]).
+ integer_absorption/1,
+ integer_associativity/1]).
suite() ->
[{ct_hooks,[ts_install_cth]}].
@@ -40,7 +41,8 @@ suite() ->
all() ->
[{group,property_tests},
binary_absorption,
- integer_absorption].
+ integer_absorption,
+ integer_associativity].
groups() ->
[{property_tests,[parallel],
@@ -91,15 +93,32 @@ binary_absorption(Config) when is_list(Config) ->
ok.
integer_absorption(Config) when is_list(Config) ->
- %% Integers that don't overlap fully should never meet.
- A = #t_integer{elements={3,5}},
- B = #t_integer{elements={4,6}},
+ %% Integers that don't overlap at all should never meet.
+ A = #t_integer{elements={2,3}},
+ B = #t_integer{elements={4,5}},
none = beam_types:meet(A, B),
- #t_integer{elements={3,6}} = beam_types:join(A, B),
+ #t_integer{elements={2,5}} = beam_types:join(A, B),
A = beam_types:meet(A, beam_types:join(A, B)),
A = beam_types:join(A, beam_types:meet(A, B)),
ok.
+integer_associativity(Config) when is_list(Config) ->
+ A = #t_integer{elements={3,5}},
+ B = #t_integer{elements={4,6}},
+ C = #t_integer{elements={5,5}},
+
+ %% a ∨ (b ∨ c) = (a ∨ b) ∨ c,
+ LHS_Join = beam_types:join(A, beam_types:join(B, C)),
+ RHS_Join = beam_types:join(beam_types:join(A, B), C),
+ #t_integer{elements={3,6}} = LHS_Join = RHS_Join,
+
+ %% a ∧ (b ∧ c) = (a ∧ b) ∧ c.
+ LHS_Meet = beam_types:meet(A, beam_types:meet(B, C)),
+ RHS_Meet = beam_types:meet(beam_types:meet(A, B), C),
+ #t_integer{elements={5,5}} = LHS_Meet = RHS_Meet,
+
+ ok.
+