Permalink
Browse files

add code in test/

  • Loading branch information...
1 parent c2e72f0 commit 94aade7ee86eb319b0fcfc866a58e5b74552bafe @cannedprimates cannedprimates committed Jan 16, 2013
Showing with 493 additions and 0 deletions.
  1. +41 −0 test/macro_tests.erl
  2. +20 −0 test/meck_test_mod.erl
  3. +70 −0 test/test_cache.erl
  4. +34 −0 test/test_db.erl
  5. +21 −0 test/test_module.erl
  6. +235 −0 test/tulib_pool_proper_test.erl
  7. +72 −0 test/tulib_pool_test_worker.erl
View
@@ -0,0 +1,41 @@
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%% @doc Test include/
+%%% @copyright 2012 Klarna AB
+%%% @end
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+%%%
+%%% Copyright 2011-2013 Klarna AB
+%%%
+%%% Licensed under the Apache License, Version 2.0 (the "License");
+%%% you may not use this file except in compliance with the License.
+%%% You may obtain a copy of the License at
+%%%
+%%% http://www.apache.org/licenses/LICENSE-2.0
+%%%
+%%% Unless required by applicable law or agreed to in writing, software
+%%% distributed under the License is distributed on an "AS IS" BASIS,
+%%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+%%% See the License for the specific language governing permissions and
+%%% limitations under the License.
+%%%
+
+-module(macro_tests).
+-export([ assert_test/0
+ ]).
+-include_lib("tulib/include/assert.hrl").
+-include_lib("tulib/include/prelude.hrl").
+
+assert_test() ->
+ ok = ?hence(1=:=1),
+ {error, {assert, _, _, _}} = ?lift(?hence(1=:=2)),
+ ok = ?given(1=:=1, 2=:=2),
+ ok = ?given(1=:=2, 2=:=3),
+ {error, {assert, _, _, _}} = ?lift(?given(1=:=1, 2=:=3)),
+ ok = ?match(foo, foo),
+ {error, {assert, _, _, _}} = ?lift(?match(foo, bar)),
+ ok.
+
+%%% Local Variables:
+%%% erlang-indent-level: 2
+%%% End:
View
@@ -0,0 +1,20 @@
+%%%
+%%% Copyright 2011-2013 Klarna AB
+%%%
+%%% Licensed under the Apache License, Version 2.0 (the "License");
+%%% you may not use this file except in compliance with the License.
+%%% You may obtain a copy of the License at
+%%%
+%%% http://www.apache.org/licenses/LICENSE-2.0
+%%%
+%%% Unless required by applicable law or agreed to in writing, software
+%%% distributed under the License is distributed on an "AS IS" BASIS,
+%%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+%%% See the License for the specific language governing permissions and
+%%% limitations under the License.
+%%%
+
+-module(meck_test_mod).
+-compile(export_all).
+f(x) -> foo;
+f(y) -> bar.
View
@@ -0,0 +1,70 @@
+%%%
+%%% Copyright 2011-2013 Klarna AB
+%%%
+%%% Licensed under the Apache License, Version 2.0 (the "License");
+%%% you may not use this file except in compliance with the License.
+%%% You may obtain a copy of the License at
+%%%
+%%% http://www.apache.org/licenses/LICENSE-2.0
+%%%
+%%% Unless required by applicable law or agreed to in writing, software
+%%% distributed under the License is distributed on an "AS IS" BASIS,
+%%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+%%% See the License for the specific language governing permissions and
+%%% limitations under the License.
+%%%
+
+-module(test_cache).
+-behaviour(tulib_gen_cache).
+
+-export([ hit/2
+ , init/1
+ , invalid/2
+ , miss/2
+ , replace/2
+ ]).
+
+-export([ fetch/2
+ , store/3
+ ]).
+
+-export([ insert/3
+ , invalidate/2
+ , lookup/2
+ , start/0
+ , start_link/0
+ , stop/0
+ ]).
+
+hit('', _) -> ''.
+init(_) -> tulib_processes:spawn_register(fun dict/0, xyzzy),
+ tulib_processes:sync_registered(xyzzy),
+ ''.
+invalid('', _) -> ''.
+miss('', _) -> ''.
+replace('', _) -> {'', []}.
+
+fetch(Tab, Key) -> tulib_processes:call(xyzzy, {fetch, Tab, Key}).
+store(Tab, Key, Val) -> tulib_processes:send(xyzzy, {store, Tab, Key, Val}).
+
+dict() ->
+ receive
+ {Pid, {fetch, Tab, Key}} ->
+ ok = tulib_processes:send(Pid, get({Tab, Key})),
+ dict();
+ {_Pid, {store, Tab, Key, Val}} ->
+ put({Tab, Key}, Val),
+ dict()
+ end.
+
+
+invalidate(_, _) -> throw(nyi).
+insert(_, _, _) -> throw(nyi).
+lookup(_, _) -> throw(nyi).
+start() -> throw(nyi).
+start_link() -> throw(nyi).
+stop() -> throw(nyi).
+
+%%% Local Variables:
+%%% erlang-indent-level: 2
+%%% End:
View
@@ -0,0 +1,34 @@
+%%%
+%%% Copyright 2011-2013 Klarna AB
+%%%
+%%% Licensed under the Apache License, Version 2.0 (the "License");
+%%% you may not use this file except in compliance with the License.
+%%% You may obtain a copy of the License at
+%%%
+%%% http://www.apache.org/licenses/LICENSE-2.0
+%%%
+%%% Unless required by applicable law or agreed to in writing, software
+%%% distributed under the License is distributed on an "AS IS" BASIS,
+%%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+%%% See the License for the specific language governing permissions and
+%%% limitations under the License.
+%%%
+
+-module(test_db).
+-behaviour(tulib_gen_db).
+
+-export([ do_delete/2
+ , do_insert/2
+ , do_lookup/2
+ , init/1
+ ]).
+
+init(_) -> {ok, []}.
+do_delete(Lst, Elt) -> {ok, Lst -- [Elt]}.
+do_insert(_, 42) -> {error, 42};
+do_insert(Lst, Elt) -> {ok, [Elt|Lst]}.
+do_lookup(Lst, Elt) -> lists:member(Elt, Lst).
+
+%%% Local Variables:
+%%% erlang-indent-level: 2
+%%% End:
View
@@ -0,0 +1,21 @@
+%%%
+%%% Copyright 2011-2013 Klarna AB
+%%%
+%%% Licensed under the Apache License, Version 2.0 (the "License");
+%%% you may not use this file except in compliance with the License.
+%%% You may obtain a copy of the License at
+%%%
+%%% http://www.apache.org/licenses/LICENSE-2.0
+%%%
+%%% Unless required by applicable law or agreed to in writing, software
+%%% distributed under the License is distributed on an "AS IS" BASIS,
+%%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+%%% See the License for the specific language governing permissions and
+%%% limitations under the License.
+%%%
+
+-module(test_module).
+-export([]).
+-ignore_xref([unexported/0]).
+-compile({nowarn_unused_function, [{unexported, 0}]}).
+unexported() -> ok.
Oops, something went wrong.

0 comments on commit 94aade7

Please sign in to comment.