Sha256: 55d45090522d0a80afa02250e233fda834f7f5345bc347927b737bf62f31ebf2

Contents?: true

Size: 919 Bytes

Versions: 262

Compression:

Stored size: 919 Bytes

Contents

use "example.sml";

val test_cases = [
    ("0",          0),
    ("01",         1),
    ("10",         2),
    ("11",         3),
    ("100",        4),
    ("1111",      15),
    ("10000000", 128)
];

val error_test_cases = [
    ("",     EmptyBinaryStringFound),
    ("200",  NonBinaryDigitFound),
    ("a62b", NonBinaryDigitFound)
];

fun run_tests [] = []
  | run_tests ((bin_string,expected)::ts) =
       (binaryToDecimal bin_string = expected) :: run_tests ts

fun run_error_tests [] = []
  | run_error_tests ((bin_string,expected: exn)::ts) =
       (binaryToDecimal bin_string handle expected => 1) :: run_error_tests ts

val allNormalTestsPass =
    List.foldl (fn (x,y) => x andalso y) true (run_tests test_cases)
val allErrorTestsPass =
    (List.foldl (fn (x,y) => x + y) 0 (run_error_tests error_test_cases)) = length error_test_cases
val allTestsPass = allNormalTestsPass andalso allErrorTestsPass
    

Version data entries

262 entries across 262 versions & 1 rubygems

Version Path
trackler-2.2.1.44 tracks/sml/exercises/binary/test.sml
trackler-2.2.1.43 tracks/sml/exercises/binary/test.sml
trackler-2.2.1.42 tracks/sml/exercises/binary/test.sml
trackler-2.2.1.41 tracks/sml/exercises/binary/test.sml
trackler-2.2.1.40 tracks/sml/exercises/binary/test.sml
trackler-2.2.1.39 tracks/sml/exercises/binary/test.sml
trackler-2.2.1.38 tracks/sml/exercises/binary/test.sml
trackler-2.2.1.37 tracks/sml/exercises/binary/test.sml
trackler-2.2.1.36 tracks/sml/exercises/binary/test.sml
trackler-2.2.1.35 tracks/sml/exercises/binary/test.sml
trackler-2.2.1.34 tracks/sml/exercises/binary/test.sml
trackler-2.2.1.33 tracks/sml/exercises/binary/test.sml
trackler-2.2.1.32 tracks/sml/exercises/binary/test.sml
trackler-2.2.1.31 tracks/sml/exercises/binary/test.sml
trackler-2.2.1.30 tracks/sml/exercises/binary/test.sml
trackler-2.2.1.29 tracks/sml/exercises/binary/test.sml
trackler-2.2.1.28 tracks/sml/exercises/binary/test.sml
trackler-2.2.1.27 tracks/sml/exercises/binary/test.sml
trackler-2.2.1.26 tracks/sml/exercises/binary/test.sml
trackler-2.2.1.25 tracks/sml/exercises/binary/test.sml