From 88f1c3d39521ce4725db8e5b56ff7658d1181d0b Mon Sep 17 00:00:00 2001 From: Vitali Shulha Date: Tue, 6 Aug 2024 12:51:14 +0400 Subject: [PATCH 1/2] Create FSharp/Calculator/Calc.fs --- FSharp/Calculator/Calc.fs | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 FSharp/Calculator/Calc.fs diff --git a/FSharp/Calculator/Calc.fs b/FSharp/Calculator/Calc.fs new file mode 100644 index 0000000..001be20 --- /dev/null +++ b/FSharp/Calculator/Calc.fs @@ -0,0 +1,9 @@ +module Calculator + +let sum a b = a + b + +let subtract a b = a - b + +let multiply a b = a * b + +let divide a b = a / b \ No newline at end of file From 6cf65ba88f97bedf9f82a1cf2325a4312dfe3dc7 Mon Sep 17 00:00:00 2001 From: Vitali Shulha Date: Tue, 6 Aug 2024 12:51:52 +0400 Subject: [PATCH 2/2] Create FSharp/CalculatorTest/TestCalculator.fs --- FSharp/CalculatorTest/TestCalculator.fs | 28 +++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 FSharp/CalculatorTest/TestCalculator.fs diff --git a/FSharp/CalculatorTest/TestCalculator.fs b/FSharp/CalculatorTest/TestCalculator.fs new file mode 100644 index 0000000..f975e0c --- /dev/null +++ b/FSharp/CalculatorTest/TestCalculator.fs @@ -0,0 +1,28 @@ +module TestCalculator + +open NUnit.Framework +open FsUnit +open Calculator + +[] +type TestCalculator() = + + [] + member this.Setup() = printfn "Starting Calculator tests" + + [] + member this.TearDown() = printfn "Calculator tests are finished" + + [] + [] + member this.OneCanSumPositiveIntegers() = Calc.sum 5 5 |> should equal 10 + + [] + [] + member this.OneCanSumNegativeIntegers() = Calc.sum -5 -5 |> should equal -10 + + [] + [] + member this.OneCanSubtractPositiveIntegers() = Calc.subtract 5 5 |> should equal 0 + + // Remaining test cases translated similarly \ No newline at end of file