Skip to content

Commit 1c96110

Browse files
forth
1 parent 8c3b6f3 commit 1c96110

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

exercises/practice/forth/.meta/Generator.tpl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@ public class {{ testClass }}
88
public void {{ test.testMethod }}()
99
{
1010
{{- if test.expected.error }}
11-
Assert.Throws<InvalidOperationException>(() => {{ testedClass }}.{{ test.testedMethod }}({{ test.input.instructions }}));
11+
Assert.Throws<{{ if test.expected.error == "divide by zero" }}DivideByZeroException{{ else }}InvalidOperationException{{ end }}>(() => {{ testedClass }}.{{ test.testedMethod }}({{ test.input.instructions }}));
12+
{{ else if test.property == "evaluateBoth" }}
13+
Assert.Equal("{{test.expected[0] | array.join " "}}", {{ testedClass }}.Evaluate({{ test.input.instructionsFirst }}));
14+
Assert.Equal("{{test.expected[1] | array.join " "}}", {{ testedClass }}.Evaluate({{ test.input.instructionsSecond }}));
1215
{{ else }}
1316
Assert.Equal("{{test.expected | array.join " "}}", {{ testedClass }}.{{ test.testedMethod }}({{ test.input.instructions }}));
1417
{{ end -}}

exercises/practice/forth/ForthTests.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ public void Division_performs_integer_division()
102102
[Fact(Skip = "Remove this Skip property to run this test")]
103103
public void Division_errors_if_dividing_by_zero()
104104
{
105-
Assert.Throws<InvalidOperationException>(() => Forth.Evaluate(["4 0 /"]));
105+
Assert.Throws<DivideByZeroException>(() => Forth.Evaluate(["4 0 /"]));
106106
}
107107

108108
[Fact(Skip = "Remove this Skip property to run this test")]
@@ -294,7 +294,8 @@ public void User_defined_words_errors_if_executing_a_non_existent_word()
294294
[Fact(Skip = "Remove this Skip property to run this test")]
295295
public void User_defined_words_only_defines_locally()
296296
{
297-
Assert.Equal("[0] [2]", Forth.EvaluateBoth());
297+
Assert.Equal("0", Forth.Evaluate([": + - ;", "1 1 +"]));
298+
Assert.Equal("2", Forth.Evaluate(["1 1 +"]));
298299
}
299300

300301
[Fact(Skip = "Remove this Skip property to run this test")]

0 commit comments

Comments
 (0)