From c3b086d38bd152af39381bfae96c1e9ce7e7be9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= Date: Thu, 12 Aug 2010 16:20:20 +0200 Subject: Add test suite for debugger --- lib/debugger/test/debugger_test.erl | 154 ++++++++++++++++++++++++++++++++++++ 1 file changed, 154 insertions(+) create mode 100644 lib/debugger/test/debugger_test.erl (limited to 'lib/debugger/test/debugger_test.erl') diff --git a/lib/debugger/test/debugger_test.erl b/lib/debugger/test/debugger_test.erl new file mode 100644 index 0000000000..a64bed5db1 --- /dev/null +++ b/lib/debugger/test/debugger_test.erl @@ -0,0 +1,154 @@ +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 1998-2010. All Rights Reserved. +%% +%% The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved online at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% %CopyrightEnd% +%% + +%% +%%%---------------------------------------------------------------------- +%%% Purpose : This is the test module to be used in with the test cases +%%% in the debugger test document. +%%%---------------------------------------------------------------------- + +-module(debugger_test). + + +-export ([installation_ok/0, + list/0, + fac/1, + c_break/1]). + + +-define (INT_DIR, "misc"). % The directory of the Interpreter directory +-define (INT, "interpreter"). % The Interpreter directory name. +-define (DBG, "debugger"). % Debugger name + + +%%% installation_ok /0 +%%% + +installation_ok () -> + debugger_ok (), + interpreter_ok (). + + + +%%% debugger_ok /0 +%%% + +debugger_ok () -> + L = code:get_path (), + + case debugger_in_codepath (L) of + {true, Msg} -> + out_put (Msg); + + Other -> + out_put (Other) + end. + + + +%%% debugger_in_codepath /2 +%%% + +debugger_in_codepath ([]) -> + Msg = io_lib:format ("False: ~s not in code path", [?DBG]), + lists:flatten (Msg); + +debugger_in_codepath ([Path | T]) -> + case string:str (Path, ?DBG) =/= 0 of + true -> + Msg = io_lib:format ("Ok: ~s in code path (~s)", [?DBG, Path]), + Msg1 = lists:flatten (Msg), + {true, Msg1}; + + _Other -> + debugger_in_codepath (T) + end. + + + +%%% interpreter_ok /0 +%%% + +interpreter_ok () -> + Root_dir = code:root_dir (), + Misc_dir = filename:join (Root_dir, ?INT_DIR), + + In_misc = case file:list_dir (Misc_dir) of + {ok, L} -> + lists:member (?INT, L); + + Other -> + Other + end, + + case In_misc of + true -> + Msg = io_lib:format ("Ok: ~s is in ~s", [?INT, ?INT_DIR]), + Msg1 = lists:flatten (Msg), + out_put (Msg1); + + Other1 -> + Msg = io_lib:format ("Error: interpreter in misc - ~s", [Other1]), + Msg1 = lists:flatten (Msg), + out_put (Msg1) + end. + + + +%%% list /0 +%%% + +list () -> + A = [1, 2, 3, 4, 5], + B = [a, b, c, d, e], + lists:append (A, B). + + + +%%% fac /1 +%%% + +fac (0) -> + 1; + + +fac (N) -> + N * fac (N - 1). + + + +%%% c_break /1 +%%% + +c_break (Bindings) -> + case int:get_binding ('N', Bindings) of + {value, 3} -> + true; + + _Other -> + false + end. + + + +%%% out_put /1 +%%% + +out_put (X) -> + io:format ("~n~p~n", [X]). -- cgit v1.2.3