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.159 tracks/sml/exercises/difference-of-squares/test.sml
trackler-2.2.1.158 tracks/sml/exercises/difference-of-squares/test.sml
trackler-2.2.1.157 tracks/sml/exercises/difference-of-squares/test.sml
trackler-2.2.1.156 tracks/sml/exercises/difference-of-squares/test.sml
trackler-2.2.1.155 tracks/sml/exercises/difference-of-squares/test.sml
trackler-2.2.1.154 tracks/sml/exercises/difference-of-squares/test.sml
trackler-2.2.1.153 tracks/sml/exercises/difference-of-squares/test.sml
trackler-2.2.1.152 tracks/sml/exercises/difference-of-squares/test.sml
trackler-2.2.1.151 tracks/sml/exercises/difference-of-squares/test.sml
trackler-2.2.1.150 tracks/sml/exercises/difference-of-squares/test.sml
trackler-2.2.1.149 tracks/sml/exercises/difference-of-squares/test.sml
trackler-2.2.1.148 tracks/sml/exercises/difference-of-squares/test.sml
trackler-2.2.1.147 tracks/sml/exercises/difference-of-squares/test.sml
trackler-2.2.1.146 tracks/sml/exercises/difference-of-squares/test.sml
trackler-2.2.1.145 tracks/sml/exercises/difference-of-squares/test.sml
trackler-2.2.1.144 tracks/sml/exercises/difference-of-squares/test.sml
trackler-2.2.1.143 tracks/sml/exercises/difference-of-squares/test.sml
trackler-2.2.1.142 tracks/sml/exercises/difference-of-squares/test.sml
trackler-2.2.1.141 tracks/sml/exercises/difference-of-squares/test.sml
trackler-2.2.1.140 tracks/sml/exercises/difference-of-squares/test.sml