Sha256: 607177019221469e7062a885b944b614130ac4c5f1cec03ac4fe97006688b943

Contents?: true

Size: 1.23 KB

Versions: 163

Compression:

Stored size: 1.23 KB

Contents

(* version 1.1.0 *)

use "difference-of-squares.sml";
use "testlib.sml";

infixr |>
fun x |> f = f x

val testsuite =
  describe "difference-of-squares" [
    describe "Square the sum of the numbers up to the given number" [
      test "square of sum 1"
        (fn _ => squareOfSum (1) |> Expect.equalTo 1),

      test "square of sum 5"
        (fn _ => squareOfSum (5) |> Expect.equalTo 225),

      test "square of sum 100"
        (fn _ => squareOfSum (100) |> Expect.equalTo 25502500)
    ],

    describe "Sum the squares of the numbers up to the given number" [
      test "sum of squares 1"
        (fn _ => sumOfSquares (1) |> Expect.equalTo 1),

      test "sum of squares 5"
        (fn _ => sumOfSquares (5) |> Expect.equalTo 55),

      test "sum of squares 100"
        (fn _ => sumOfSquares (100) |> Expect.equalTo 338350)
    ],

    describe "Subtract sum of squares from square of sums" [
      test "difference of squares 1"
        (fn _ => differenceOfSquares (1) |> Expect.equalTo 0),

      test "difference of squares 5"
        (fn _ => differenceOfSquares (5) |> Expect.equalTo 170),

      test "difference of squares 100"
        (fn _ => differenceOfSquares (100) |> Expect.equalTo 25164150)
    ]
  ]

val _ = Test.run testsuite

Version data entries

163 entries across 163 versions & 1 rubygems

Version Path
trackler-2.2.1.180 tracks/sml/exercises/difference-of-squares/test.sml
trackler-2.2.1.179 tracks/sml/exercises/difference-of-squares/test.sml
trackler-2.2.1.178 tracks/sml/exercises/difference-of-squares/test.sml
trackler-2.2.1.177 tracks/sml/exercises/difference-of-squares/test.sml
trackler-2.2.1.176 tracks/sml/exercises/difference-of-squares/test.sml
trackler-2.2.1.175 tracks/sml/exercises/difference-of-squares/test.sml
trackler-2.2.1.174 tracks/sml/exercises/difference-of-squares/test.sml
trackler-2.2.1.173 tracks/sml/exercises/difference-of-squares/test.sml
trackler-2.2.1.172 tracks/sml/exercises/difference-of-squares/test.sml
trackler-2.2.1.171 tracks/sml/exercises/difference-of-squares/test.sml
trackler-2.2.1.170 tracks/sml/exercises/difference-of-squares/test.sml
trackler-2.2.1.169 tracks/sml/exercises/difference-of-squares/test.sml
trackler-2.2.1.167 tracks/sml/exercises/difference-of-squares/test.sml
trackler-2.2.1.166 tracks/sml/exercises/difference-of-squares/test.sml
trackler-2.2.1.165 tracks/sml/exercises/difference-of-squares/test.sml
trackler-2.2.1.164 tracks/sml/exercises/difference-of-squares/test.sml
trackler-2.2.1.163 tracks/sml/exercises/difference-of-squares/test.sml
trackler-2.2.1.162 tracks/sml/exercises/difference-of-squares/test.sml
trackler-2.2.1.161 tracks/sml/exercises/difference-of-squares/test.sml
trackler-2.2.1.160 tracks/sml/exercises/difference-of-squares/test.sml