From f7d4119fdaf3fd2a5f5d545d3886f39522122ab5 Mon Sep 17 00:00:00 2001 From: belltoy Date: Mon, 19 Aug 2024 15:34:34 +0800 Subject: [PATCH] Simplify test cases, make them as realistic as possible --- test/examples/fail_state_record_and_type.erl | 17 +---------- .../fail_state_record_and_type_behaviour.erl | 17 +---------- ...record_and_type_plus_export_used_types.erl | 29 +++++-------------- test/examples/pass_state_record_and_type.erl | 29 +++++-------------- .../pass_state_record_and_type_elvis_attr.erl | 29 +++++-------------- .../pass_state_record_and_type_opaque.erl | 29 +++++-------------- ...record_and_type_plus_export_used_types.erl | 29 +++++-------------- 7 files changed, 37 insertions(+), 142 deletions(-) diff --git a/test/examples/fail_state_record_and_type.erl b/test/examples/fail_state_record_and_type.erl index ec811b37..c31ef141 100644 --- a/test/examples/fail_state_record_and_type.erl +++ b/test/examples/fail_state_record_and_type.erl @@ -7,10 +7,7 @@ -export([ init/1, handle_call/3, - handle_cast/2, - handle_info/2, - code_change/3, - terminate/2 + handle_cast/2 ]). -spec init(term()) -> ok. @@ -24,15 +21,3 @@ handle_call(_Request, _From, _State) -> -spec handle_cast(term(), term()) -> ok. handle_cast(_Request, _State) -> ok. - --spec handle_info(term(), term()) -> ok. -handle_info(_Info, _State) -> - ok. - --spec code_change(term(), term(), term()) -> term(). -code_change(_OldVsn, State, _Extra) -> - {ok, State}. - --spec terminate(term(), term()) -> ok. -terminate(_Reason, _State) -> - ok. diff --git a/test/examples/fail_state_record_and_type_behaviour.erl b/test/examples/fail_state_record_and_type_behaviour.erl index 88f5f7f0..3caba161 100644 --- a/test/examples/fail_state_record_and_type_behaviour.erl +++ b/test/examples/fail_state_record_and_type_behaviour.erl @@ -7,10 +7,7 @@ -export([ init/1, handle_call/3, - handle_cast/2, - handle_info/2, - code_change/3, - terminate/2 + handle_cast/2 ]). -spec init(term()) -> ok. @@ -24,15 +21,3 @@ handle_call(_Request, _From, _State) -> -spec handle_cast(term(), term()) -> ok. handle_cast(_Request, _State) -> ok. - --spec handle_info(term(), term()) -> ok. -handle_info(_Info, _State) -> - ok. - --spec code_change(term(), term(), term()) -> term(). -code_change(_OldVsn, State, _Extra) -> - {ok, State}. - --spec terminate(term(), term()) -> ok. -terminate(_Reason, _State) -> - ok. diff --git a/test/examples/fail_state_record_and_type_plus_export_used_types.erl b/test/examples/fail_state_record_and_type_plus_export_used_types.erl index f0ece13d..3cc5de64 100644 --- a/test/examples/fail_state_record_and_type_plus_export_used_types.erl +++ b/test/examples/fail_state_record_and_type_plus_export_used_types.erl @@ -7,10 +7,7 @@ -export([ init/1, handle_call/3, - handle_cast/2, - handle_info/2, - code_change/3, - terminate/2 + handle_cast/2 ]). -record(state, {}). @@ -21,22 +18,10 @@ init(_Args) -> #state{}. --spec handle_call(term(), term(), term()) -> ok. -handle_call(_Request, _From, _State) -> - ok. +-spec handle_call(term(), term(), state()) -> {noreply, state()}. +handle_call(_Request, _From, State) -> + {noreply, State}. --spec handle_cast(term(), term()) -> ok. -handle_cast(_Request, _State) -> - ok. - --spec handle_info(term(), term()) -> ok. -handle_info(_Info, _State) -> - ok. - --spec code_change(term(), term(), term()) -> term(). -code_change(_OldVsn, State, _Extra) -> - {ok, State}. - --spec terminate(term(), term()) -> ok. -terminate(_Reason, _State) -> - ok. +-spec handle_cast(term(), state()) -> {noreply, state()}. +handle_cast(_Request, State) -> + {noreply, State}. diff --git a/test/examples/pass_state_record_and_type.erl b/test/examples/pass_state_record_and_type.erl index a09c7507..04e34e9c 100644 --- a/test/examples/pass_state_record_and_type.erl +++ b/test/examples/pass_state_record_and_type.erl @@ -7,10 +7,7 @@ -export([ init/1, handle_call/3, - handle_cast/2, - handle_info/2, - code_change/3, - terminate/2 + handle_cast/2 ]). -record(state, {}). @@ -21,22 +18,10 @@ init(_Args) -> #state{}. --spec handle_call(term(), term(), term()) -> ok. -handle_call(_Request, _From, _State) -> - ok. +-spec handle_call(term(), term(), state()) -> {noreply, state()}. +handle_call(_Request, _From, State) -> + {noreply, State}. --spec handle_cast(term(), term()) -> ok. -handle_cast(_Request, _State) -> - ok. - --spec handle_info(term(), term()) -> ok. -handle_info(_Info, _State) -> - ok. - --spec code_change(term(), term(), term()) -> term(). -code_change(_OldVsn, State, _Extra) -> - {ok, State}. - --spec terminate(term(), term()) -> ok. -terminate(_Reason, _State) -> - ok. +-spec handle_cast(term(), state()) -> {noreply, state()}. +handle_cast(_Request, State) -> + {noreply, State}. diff --git a/test/examples/pass_state_record_and_type_elvis_attr.erl b/test/examples/pass_state_record_and_type_elvis_attr.erl index e8fb5984..839f5a4e 100644 --- a/test/examples/pass_state_record_and_type_elvis_attr.erl +++ b/test/examples/pass_state_record_and_type_elvis_attr.erl @@ -7,10 +7,7 @@ -export([ init/1, handle_call/3, - handle_cast/2, - handle_info/2, - code_change/3, - terminate/2 + handle_cast/2 ]). -elvis([{elvis_style, state_record_and_type, disable}]). @@ -19,22 +16,10 @@ init(_Args) -> ok. --spec handle_call(term(), term(), term()) -> ok. -handle_call(_Request, _From, _State) -> - ok. - --spec handle_cast(term(), term()) -> ok. -handle_cast(_Request, _State) -> - ok. +-spec handle_call(term(), term(), term()) -> {noreply, term()}. +handle_call(_Request, _From, State) -> + {noreply, State}. --spec handle_info(term(), term()) -> ok. -handle_info(_Info, _State) -> - ok. - --spec code_change(term(), term(), term()) -> term(). -code_change(_OldVsn, State, _Extra) -> - {ok, State}. - --spec terminate(term(), term()) -> ok. -terminate(_Reason, _State) -> - ok. +-spec handle_cast(term(), term()) -> {noreply, term()}. +handle_cast(_Request, State) -> + {noreply, State}. diff --git a/test/examples/pass_state_record_and_type_opaque.erl b/test/examples/pass_state_record_and_type_opaque.erl index 2d83cee5..b086b46d 100644 --- a/test/examples/pass_state_record_and_type_opaque.erl +++ b/test/examples/pass_state_record_and_type_opaque.erl @@ -7,10 +7,7 @@ -export([ init/1, handle_call/3, - handle_cast/2, - handle_info/2, - code_change/3, - terminate/2 + handle_cast/2 ]). -export_type([state/0]). @@ -23,22 +20,10 @@ init(_Args) -> #state{}. --spec handle_call(term(), term(), term()) -> ok. -handle_call(_Request, _From, _State) -> - ok. +-spec handle_call(term(), term(), state()) -> {noreply, state()}. +handle_call(_Request, _From, State) -> + {noreply, State}. --spec handle_cast(term(), term()) -> ok. -handle_cast(_Request, _State) -> - ok. - --spec handle_info(term(), term()) -> ok. -handle_info(_Info, _State) -> - ok. - --spec code_change(term(), term(), term()) -> term(). -code_change(_OldVsn, State, _Extra) -> - {ok, State}. - --spec terminate(term(), term()) -> ok. -terminate(_Reason, _State) -> - ok. +-spec handle_cast(term(), state()) -> {noreply, state()}. +handle_cast(_Request, State) -> + {noreply, State}. diff --git a/test/examples/pass_state_record_and_type_plus_export_used_types.erl b/test/examples/pass_state_record_and_type_plus_export_used_types.erl index 73018132..67d0f715 100644 --- a/test/examples/pass_state_record_and_type_plus_export_used_types.erl +++ b/test/examples/pass_state_record_and_type_plus_export_used_types.erl @@ -7,10 +7,7 @@ -export([ init/1, handle_call/3, - handle_cast/2, - handle_info/2, - code_change/3, - terminate/2 + handle_cast/2 ]). -export_type([state/0]). @@ -23,22 +20,10 @@ init(_Args) -> #state{}. --spec handle_call(term(), term(), term()) -> ok. -handle_call(_Request, _From, _State) -> - ok. +-spec handle_call(term(), term(), state()) -> {noreply, state()}. +handle_call(_Request, _From, State) -> + {noreply, State}. --spec handle_cast(term(), term()) -> ok. -handle_cast(_Request, _State) -> - ok. - --spec handle_info(term(), term()) -> ok. -handle_info(_Info, _State) -> - ok. - --spec code_change(term(), term(), term()) -> term(). -code_change(_OldVsn, State, _Extra) -> - {ok, State}. - --spec terminate(term(), term()) -> ok. -terminate(_Reason, _State) -> - ok. +-spec handle_cast(term(), state()) -> {noreply, state()}. +handle_cast(_Request, State) -> + {noreply, State}.