Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added test framework - see test_cluster_chart.e for example of test file

  • Loading branch information...
commit 90d69dd0ab8f36e9fe6f6df61c37c3946e264515 1 parent f4372f4
@tdidriksen authored
View
4 src/type_checker/tbon_tc_error.e
@@ -21,7 +21,9 @@ feature -- Initialization
-- Initialize `Current'.
do
code := an_error_code
- message := an_error_message.string
+ if an_error_message /= Void then
+ message := an_error_message.string
+ end
end
feature -- Access
View
6 src/type_checker/tbon_tc_warning.e
@@ -17,11 +17,13 @@ create
make
feature -- Initialization
- make (an_error_code: INTEGER; an_error_message: STRING)
+ make (an_error_code: INTEGER; a_warning_message: STRING)
-- Initialize `Current'.
do
code := an_error_code
- message := an_error_message.string
+ if a_warning_message /= Void then
+ message := a_warning_message.string
+ end
end
feature -- Access
View
37 test/type_checker/TESTGEN/type_checker_test.e
@@ -1,37 +0,0 @@
-note
-
- description: "Test harness root class"
- generator: "getest version 3.9"
-
-class TYPE_CHECKER_TEST
-
-inherit
-
- TS_TESTER
- redefine
- build_suite
- end
-
-create
-
- make, make_default
-
-feature -- Element change
-
- build_suite
- -- Add to `suite' the test cases that need to executed.
- local
- l_regexp: like enabled_test_cases
- l_name: STRING
- l_test1: TEST_CLUSTER_CHART
- do
- l_regexp := enabled_test_cases
- l_name := "TEST_CLUSTER_CHART.test_true"
- if l_regexp = Void or else l_regexp.recognizes (l_name) then
- create l_test1.make_default
- l_test1.set_test (l_name, agent l_test1.test_true)
- put_test (l_test1)
- end
- end
-
-end
View
0  test/type_checker/class_chart.bon → test/type_checker/bon/class_chart.bon
File renamed without changes
View
42 test/type_checker/bon/cluster_does_not_exist.bon
@@ -0,0 +1,42 @@
+system_chart THE_WORLD
+ cluster EARTH description "A small, insignificant planet."
+end
+
+class_chart CITIZEN
+indexing
+ clauster: "CIVIL_STATUS " ;
+ created: "1993-03-15 jmn";
+ revised: "1993-05-12 kw"
+explanation
+ "Person born or living in a country"
+part "1/1 "
+query
+ "Name", "Sex", "Age", "Single", "Spouse", "Children", "Parents",
+ "Impediment to marriage"
+command
+ "Marry", "Divorce"
+constraint
+ "Each citizen has two parents.",
+ "At most one spouse allowed.",
+ "May not marry children or parents or person of same sex.",
+ "Spouse's spouse must be this person.",
+ "All children, if any, must have this person among their parents."
+end
+
+class_chart NOBLEPERSON
+indexing
+ cluaster: "CIVIL_STATUS" ;
+ created: "1993-03-15 jmn";
+ revised: "1993-05-12 kw", "1993-12-10 kw"
+explanation
+ "Person of noble rank"
+part "1/1 "
+inherit CITIZEN
+query
+ "Assets", "Butler"
+constraint
+ "Enough property for independence.",
+ "Can only marry other noble person.",
+ "Wedding celebrated with style.",
+ "Married nobility share their assets and must have a butler."
+end
View
72 test/type_checker/tbon_tc_test.e
@@ -0,0 +1,72 @@
+note
+ description: "Shared items for all type checker test classes."
+ author: ""
+ date: "$Date$"
+ revision: "$Revision$"
+
+class
+ TBON_TC_TEST
+
+inherit
+ TBON_TC_ERROR
+
+feature -- Access
+ parser: BON_PARSER
+
+ type_checker: TEXTUAL_BON_TYPE_CHECKER
+
+feature -- Setup
+ set_up
+ -- Do this before _first_ test.
+ do
+ create parser.make_parser
+ end
+
+ bon_specification_from_file (a_filename: STRING): BON_SPECIFICATION
+ -- Get a BON specification from `a_filename'.
+ local
+ a_file: KL_TEXT_INPUT_FILE
+ filename: STRING
+ do
+ filename := a_filename.string
+ if prepend_exec_path then
+ filename.prepend_string (exec_path)
+ end
+ create a_file.make (filename)
+ a_file.open_read
+ if a_file.is_open_read then
+ parser.reset_scanner
+ parser.set_input_buffer (parser.new_file_buffer (a_file))
+ parser.parse
+ a_file.close
+ else
+ io.set_error_default
+ io.put_string ("bon_parser: cannot read %'")
+ io.put_string (filename)
+ io.put_string ("%'%N")
+ end
+ Result := parser.bon_specification
+ end
+
+ set_up_test
+ -- Do this before _every_ test.
+ do
+ create type_checker.make
+ end
+
+feature -- Constants
+
+ prepend_exec_path: BOOLEAN = True
+ -- Should th exec_path be prepended to the path?
+
+ exec_path: STRING = "../../../bon/"
+ -- Path to BON files from executable library.
+
+feature -- Status report
+
+ error_occurred (an_error_code: INTEGER): BOOLEAN
+ do
+ Result := type_checker.errors.has (create {TBON_TC_ERROR}.make (an_error_code, Void))
+ end
+
+end
View
56 test/type_checker/test_cluster_chart.e
@@ -1,5 +1,5 @@
note
- description: "Tests for cluster charts"
+ description: "Tests for cluster charts."
author: ""
date: "$Date$"
revision: "$Revision$"
@@ -9,58 +9,36 @@ class
inherit
TS_TEST_CASE
- redefine
+ undefine
set_up
end
+ TBON_TC_TEST
+ undefine
+ is_equal
+ end
+
create
make_default
-feature -- Access
- parser: BON_PARSER
-
- type_checker: TEXTUAL_BON_TYPE_CHECKER
-
-feature -- Setup
- set_up
- do
- create parser.make_parser
- end
-
- bon_specification_from_file (a_filename: STRING): BON_SPECIFICATION
- -- Get a BON specification from `a_filename'
+feature -- Test
+ test_cluster_does_not_exist
local
- a_file: KL_TEXT_INPUT_FILE
- do
- create a_file.make (a_filename)
- a_file.open_read
- if a_file.is_open_read then
- parser.reset_scanner
- parser.set_input_buffer (parser.new_file_buffer (a_file))
- parser.parse
- a_file.close
- else
- io.set_error_default
- io.put_string ("bon_parser: cannot read %'")
- io.put_string (a_filename)
- io.put_string ("%'%N")
- end
- Result := parser.bon_specification
- end
-
- set_up_test
+ bon_spec: BON_SPECIFICATION
do
- create type_checker.make
+ set_up_test
+ bon_spec := bon_specification_from_file ("cluster_does_not_exist.bon")
+ assert_false ("Type checking failed", type_checker.check_bon_specification (bon_spec))
+ assert ("Cluster does not exist error occurred", error_occurred (err_code_cluster_does_not_exist))
end
-feature -- Test
- test_true
+ test_success
local
bon_spec: BON_SPECIFICATION
do
set_up_test
- bon_spec := bon_specification_from_file ("../../../class_chart.bon")
- assert ("Bon spec succeeds", type_checker.check_bon_specification (bon_spec))
+ bon_spec := bon_specification_from_file ("class_chart.bon")
+ assert ("Bon spec succeeded", type_checker.check_bon_specification (bon_spec))
end
end
View
4 test/type_checker/type_checker_test.ecf
@@ -12,7 +12,7 @@
</option>
<precompile name="base_pre" location="$ISE_PRECOMP\base.ecf"/>
<library name="base" location="$ISE_LIBRARY\library\base\base.ecf"/>
- <library name="base2" location="\Users\Thomas\Documents\ITU\6. semester\Bachelor\EiffelBase2\base2.ecf"/>
+ <library name="base2" location="$EIFFEL_BASE_2\base2.ecf"/>
<library name="gobo_kernel" location="$ISE_LIBRARY\library\gobo\gobo_kernel.ecf"/>
<library name="gobo_lexical" location="$ISE_LIBRARY\library\gobo\gobo_lexical.ecf"/>
<library name="gobo_parse" location="$ISE_LIBRARY\library\gobo\gobo_parse.ecf"/>
@@ -20,7 +20,7 @@
<library name="gobo_test" location="$ISE_LIBRARY\library\gobo\gobo_test.ecf"/>
<library name="gobo_utility" location="$ISE_LIBRARY\library\gobo\gobo_utility.ecf"/>
<cluster name="parser" location="$REBON\src\parser\"/>
- <cluster name="scanner" location="\Users\Thomas\Documents\ITU\6. semester\Bachelor\rEBON\src\scanner\"/>
+ <cluster name="scanner" location="$REBON\src\scanner\"/>
<cluster name="type_checker" location="$REBON\src\type_checker\" recursive="true"/>
<cluster name="type_checker_test" location=".\" recursive="true">
<cluster name="mog" location="$REBON\library\mog\" recursive="true"/>
Please sign in to comment.
Something went wrong with that request. Please try again.