Skip to content

Commit

Permalink
Finish the Gradualizer diagnostics test case
Browse files Browse the repository at this point in the history
  • Loading branch information
erszcz committed Oct 16, 2021
1 parent 4954994 commit 42bb708
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion apps/els_lsp/test/els_diagnostics_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,11 @@ init_per_testcase(TestCase, Config) when TestCase =:= compiler_telemetry ->
els_mock_diagnostics:setup(),
mock_compiler_telemetry_enabled(),
els_test_utils:init_per_testcase(TestCase, Config);
init_per_testcase(TestCase, Config) when TestCase =:= gradualizer ->
meck:new(els_gradualizer_diagnostics, [passthrough, no_link]),
meck:expect(els_gradualizer_diagnostics, is_default, 0, true),
els_mock_diagnostics:setup(),
els_test_utils:init_per_testcase(TestCase, Config);
init_per_testcase(TestCase, Config) ->
els_mock_diagnostics:setup(),
els_test_utils:init_per_testcase(TestCase, Config).
Expand Down Expand Up @@ -157,6 +162,11 @@ end_per_testcase(TestCase, Config) when TestCase =:= compiler_telemetry ->
els_test_utils:end_per_testcase(TestCase, Config),
els_mock_diagnostics:teardown(),
ok;
end_per_testcase(TestCase, Config) when TestCase =:= gradualizer ->
meck:unload(els_gradualizer_diagnostics),
els_test_utils:end_per_testcase(TestCase, Config),
els_mock_diagnostics:teardown(),
ok;
end_per_testcase(TestCase, Config) ->
els_test_utils:end_per_testcase(TestCase, Config),
els_mock_diagnostics:teardown(),
Expand Down Expand Up @@ -790,7 +800,11 @@ gradualizer(Config) ->
Diagnostics == []
andalso ct:fail("Diagnostics should not be empty - is Gradualizer "
"available in the code path?"),
Expected = [],
Expected = [#{message => <<"The variable N is expected to have type "
"integer() but it has type false | true\n">>,
range => #{'end' => #{character => 0, line => 11},
start => #{character => 0, line => 10}},
severity => 2, source => <<"Gradualizer">>}],
F = fun(#{message := M1}, #{message := M2}) -> M1 =< M2 end,
?assertEqual(Expected, lists:sort(F, Diagnostics)),
ok.
Expand Down

0 comments on commit 42bb708

Please sign in to comment.