Packages

Ceylan-WOOPER, a Wrapper for Object-Oriented Programming in Erlang, as an OTP active application here (see http://wooper.esperide.org)

Current section

Files

Jump to
wooper priv examples class_WOOPERTemplate_test.erl.sample
Raw

priv/examples/class_WOOPERTemplate_test.erl.sample

% Tests for the MYCLASS class implementation.
% See the class_MYCLASS.erl tested module.
-module(class_MYCLASS_test).
-include("test_facilities.hrl").
run() ->
test_facilities:start( ?MODULE ),
test_facilities:display( "Debug mode: ~s.",
[ class_MYCLASS:is_wooper_debug() ] ),
% General tests.
test_facilities:display(
"Statically, class name is ~s, superclasses are ~w.",
[
class_MYCLASS:getClassname(),
class_MYCLASS:get_superclasses() ] ),
MyC = class_MYCLASS:new_link(X,Y,Z),
MyC ! {getClassname,[],self()},
receive
{wooper_result,class_MYCLASS} ->
test_facilities:display(
"After constructor, getClassname returned 'class_MYCLASS' "
"as expected." );
{wooper_result,UnexpectedClass} ->
test_facilities:fail( "wrong class: ~p", [ UnexpectedClass ] )
end,
MyC ! {get_superclasses,[],self()},
receive
{wooper_result, [class_X,class_Y]} ->
test_facilities:display(
"After constructor, get_superclasses returned "
"[class_X,class_Y] as expected." );
{wooper_result,UnexpectedSuperclasses} ->
test_facilities:fail( "wrong superclasses: ~p",
[ UnexpectedSuperclasses ] )
end,
% Tests related to XXXX.
MyC ! {getX,[],self()},
receive
{wooper_result,X} ->
test_facilities:display( "getX returned X as expected.");
{wooper_result,UnexpectedX} ->
test_facilities:fail( "wrong X: ~p", [ UnexpectedAge ] )
end,
case class_MYCLASS:is_wooper_debug() of
true ->
MyC ! { wooper_get_instance_description,[], self() },
receive
{wooper_result,InspectString} ->
test_facilities:display( "Instance description: ~s",
[ InspectString ] )
end ;
false ->
ok
end,
MyC ! delete,
test_facilities:stop().