| summaryrefslogtreecommitdiff |
diff options
| author | Nathanael Sensfelder <SpamShield0@MultiAgentSystems.org> | 2020-11-03 11:03:10 +0100 |
|---|---|---|
| committer | Nathanael Sensfelder <SpamShield0@MultiAgentSystems.org> | 2020-11-03 11:03:10 +0100 |
| commit | 47ed18431dfdbbbe483ccea70518edb932595650 (patch) | |
| tree | ff9ad1b87f3629708d76c6d64d3e2ea85cb43f78 | |
| parent | 91158337a10c006971b66818cabb2e1bed3d494a (diff) | |
Starting some unit testing...
| -rw-r--r-- | data/unit-testing/Makefile | 23 | ||||
| -rw-r--r-- | data/unit-testing/access.fate | 22 | ||||
| -rw-r--r-- | src/core/src/tonkadur/fate/v1/lang/computation/Access.java | 18 | ||||
| -rw-r--r-- | src/core/src/tonkadur/fate/v1/parser/FateParser.g4 | 29 |
4 files changed, 69 insertions, 23 deletions
diff --git a/data/unit-testing/Makefile b/data/unit-testing/Makefile new file mode 100644 index 0000000..652dc05 --- /dev/null +++ b/data/unit-testing/Makefile @@ -0,0 +1,23 @@ +TONKADUR_COMPILER ?= java -jar /my/src/tonkadur/src/json-export/tonkadur_json_export_standalone.jar +TONKADUR_INTERPRETER ?= python3 /my/src/tonkadur-python-engine/tonkadur_ui.py -f + +FATE_FILES ?= $(wildcard ${CURDIR}/*.fate) +JSON_FILES ?= $(patsubst %.fate,%.fate.json,$(FATE_FILES)) +RESULT_FILES ?= $(patsubst %.fate,%.txt,$(FATE_FILES)) + +default: $(RESULT_FILES) + @echo "########" + @echo "Non-Completed tests:" + @grep -L -r COMPLETED $(RESULT_FILES) || true + @echo "########" + @echo "Failed tests:" + @grep -r FAILED $(RESULT_FILES) || true + +clean: + rm -f $(JSON_FILES) $(RESULT_FILES) + +$(RESULT_FILES): %.txt: %.fate.json + $(TONKADUR_INTERPRETER) $< > $@ + +$(JSON_FILES): %.fate.json: %.fate + $(TONKADUR_COMPILER) $< diff --git a/data/unit-testing/access.fate b/data/unit-testing/access.fate new file mode 100644 index 0000000..c829454 --- /dev/null +++ b/data/unit-testing/access.fate @@ -0,0 +1,22 @@ +(fate_version 1) + +(global (list int) li) +(global (ptr (list int)) li_ptr) + +(set li (range 0 10 1)) +(set li_ptr (ptr li)) + +(global int i) + +(for (set i 0) (< i 10) (set i (+ i 1)) + (assert (= (access li i) (var i)) + [FAILED] ACCESS assert failed on (var i) for li. + ) + (assert (= (access li_ptr i) (var i)) + [FAILED] ACCESS assert failed on (var i) with for li_ptr. + ) +) + +[COMPLETED] ACCESS + +(end) diff --git a/src/core/src/tonkadur/fate/v1/lang/computation/Access.java b/src/core/src/tonkadur/fate/v1/lang/computation/Access.java index f99d04b..1b1f2b3 100644 --- a/src/core/src/tonkadur/fate/v1/lang/computation/Access.java +++ b/src/core/src/tonkadur/fate/v1/lang/computation/Access.java @@ -17,12 +17,12 @@ import tonkadur.fate.v1.lang.meta.Reference; import tonkadur.fate.v1.lang.type.CollectionType; import tonkadur.fate.v1.lang.type.Type; -public class Access extends Reference +public class Access extends Computation { /***************************************************************************/ /**** MEMBERS **************************************************************/ /***************************************************************************/ - protected final Reference parent; + protected final Computation parent; protected final Computation index; /***************************************************************************/ @@ -32,12 +32,12 @@ public class Access extends Reference protected Access ( final Origin origin, - final Reference parent, + final Computation parent, final Type type, final Computation index ) { - super(origin, type, (parent.get_name() + "." + index.toString())); + super(origin, type); this.parent = parent; this.index = index; @@ -50,7 +50,7 @@ public class Access extends Reference public static Access build ( final Origin origin, - Reference parent, + Computation parent, final Computation index ) throws @@ -76,7 +76,7 @@ public class Access extends Reference index.get_origin(), current_type, Collections.singleton(Type.INT), - parent.get_name() + index.toString() ) ); } @@ -90,7 +90,7 @@ public class Access extends Reference origin, current_type, Collections.singleton(Type.LIST), - parent.get_name() + parent.toString() ) ); @@ -118,7 +118,7 @@ public class Access extends Reference return index; } - public Reference get_parent () + public Computation get_parent () { return parent; } @@ -132,7 +132,7 @@ public class Access extends Reference sb.append("(Access ("); sb.append(type.get_name()); sb.append(") "); - sb.append(name); + sb.append(parent.toString()); sb.append("."); sb.append(index.toString()); sb.append(")"); diff --git a/src/core/src/tonkadur/fate/v1/parser/FateParser.g4 b/src/core/src/tonkadur/fate/v1/parser/FateParser.g4 index d618513..073b521 100644 --- a/src/core/src/tonkadur/fate/v1/parser/FateParser.g4 +++ b/src/core/src/tonkadur/fate/v1/parser/FateParser.g4 @@ -3667,6 +3667,21 @@ returns [Computation result] ); } + | ACCESS_KW value_reference WS+ non_text_value R_PAREN + { + $result = + Access.build + ( + CONTEXT.get_origin_at + ( + ($ACCESS_KW.getLine()), + ($ACCESS_KW.getCharPositionInLine()) + ), + ($value_reference.result), + ($non_text_value.result) + ); + } + | FOLDL_KW fun=non_text_value WS+ init=value WS+ @@ -4854,20 +4869,6 @@ returns [Reference result] ); } - | ACCESS_KW value_reference WS+ value R_PAREN - { - $result = - Access.build - ( - CONTEXT.get_origin_at - ( - ($ACCESS_KW.getLine()), - ($ACCESS_KW.getCharPositionInLine()) - ), - ($value_reference.result), - ($value.result) - ); - } | (WORD | (VARIABLE_KW WORD WS* R_PAREN)) { |


