trackler 2.2.1.129 → 2.2.1.130
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/trackler/version.rb +1 -1
- data/problem-specifications/exercises/scale-generator/description.md +9 -16
- data/tracks/dart/config.json +9 -9
- data/tracks/dart/exercises/raindrops/lib/raindrops.dart +1 -1
- data/tracks/dart/exercises/raindrops/test/raindrops_test.dart +59 -44
- data/tracks/dart/exercises/rna-transcription/test/rna_transcription_test.dart +37 -44
- data/tracks/fsharp/exercises/go-counting/Example.fs +24 -20
- data/tracks/fsharp/exercises/go-counting/GoCountingTest.fs +110 -51
- data/tracks/fsharp/generators/Generators.fs +84 -0
- data/tracks/java/config.json +13 -13
- data/tracks/purescript/config.json +12 -0
- data/tracks/purescript/exercises/phone-number/README.md +36 -0
- data/tracks/purescript/exercises/phone-number/bower.json +26 -0
- data/tracks/purescript/exercises/phone-number/examples/src/PhoneNumber.purs +30 -0
- data/tracks/purescript/exercises/phone-number/src/PhoneNumber.purs +6 -0
- data/tracks/purescript/exercises/phone-number/test/Main.purs +50 -0
- data/tracks/rust/_test/check-stubs.sh +29 -0
- data/tracks/rust/_test/ensure-stubs-compile.sh +24 -5
- data/tracks/rust/exercises/all-your-base/src/lib.rs +1 -2
- data/tracks/rust/exercises/armstrong-numbers/src/lib.rs +2 -2
- data/tracks/rust/exercises/beer-song/src/lib.rs +2 -2
- data/tracks/rust/exercises/bob/src/lib.rs +1 -1
- data/tracks/rust/exercises/circular-buffer/tests/circular-buffer.rs +96 -101
- data/tracks/rust/exercises/collatz-conjecture/src/lib.rs +4 -2
- data/tracks/rust/exercises/decimal/.meta/description.md +1 -1
- data/tracks/rust/exercises/decimal/README.md +1 -1
- data/tracks/rust/exercises/difference-of-squares/src/lib.rs +6 -3
- data/tracks/rust/exercises/forth/src/lib.rs +1 -1
- data/tracks/rust/exercises/grade-school/src/lib.rs +2 -4
- data/tracks/rust/exercises/grains/src/lib.rs +1 -1
- data/tracks/rust/exercises/leap/src/lib.rs +1 -1
- data/tracks/rust/exercises/macros/.meta/description.md +1 -1
- data/tracks/rust/exercises/macros/README.md +1 -1
- data/tracks/rust/exercises/ocr-numbers/src/lib.rs +1 -2
- data/tracks/rust/exercises/parallel-letter-frequency/.meta/hints.md +1 -1
- data/tracks/rust/exercises/parallel-letter-frequency/README.md +1 -1
- data/tracks/rust/exercises/pascals-triangle/src/lib.rs +1 -1
- data/tracks/rust/exercises/perfect-numbers/src/lib.rs +1 -1
- data/tracks/rust/exercises/prime-factors/src/lib.rs +1 -1
- data/tracks/rust/exercises/proverb/src/lib.rs +1 -1
- data/tracks/rust/exercises/raindrops/src/lib.rs +1 -1
- data/tracks/rust/exercises/react/src/lib.rs +11 -9
- data/tracks/rust/exercises/robot-simulator/src/lib.rs +6 -4
- data/tracks/rust/exercises/saddle-points/src/lib.rs +1 -1
- data/tracks/rust/exercises/simple-linked-list/src/lib.rs +5 -5
- data/tracks/rust/exercises/space-age/src/lib.rs +6 -3
- data/tracks/rust/exercises/sum-of-multiples/src/lib.rs +1 -1
- data/tracks/rust/exercises/two-bucket/src/lib.rs +7 -1
- data/tracks/rust/exercises/variable-length-quantity/src/lib.rs +2 -2
- data/tracks/typescript/exercises/list-ops/list-ops.example.ts +9 -13
- data/tracks/typescript/exercises/list-ops/list-ops.test.ts +9 -17
- metadata +8 -4
@@ -1,78 +1,137 @@
|
|
1
|
-
// This file was
|
1
|
+
// This file was auto-generated based on version 1.0.0 of the canonical data.
|
2
2
|
|
3
3
|
module GoCountingTest
|
4
4
|
|
5
|
-
open System
|
6
|
-
|
7
|
-
open Xunit
|
8
5
|
open FsUnit.Xunit
|
6
|
+
open Xunit
|
9
7
|
|
10
8
|
open GoCounting
|
11
9
|
|
12
|
-
let board5x5 =
|
13
|
-
[" B ";
|
14
|
-
" B B ";
|
15
|
-
"B W B";
|
16
|
-
" W W ";
|
17
|
-
" W "]
|
18
|
-
|
19
|
-
let board9x9 =
|
20
|
-
[" B B ";
|
21
|
-
"B B B";
|
22
|
-
"WBBBWBBBW";
|
23
|
-
"W W W W W";
|
24
|
-
" ";
|
25
|
-
" W W W W ";
|
26
|
-
"B B B B";
|
27
|
-
" W BBB W ";
|
28
|
-
" B B "]
|
29
|
-
|
30
10
|
[<Fact>]
|
31
|
-
let ``
|
32
|
-
let
|
33
|
-
|
11
|
+
let ``Black corner territory on 5x5 board`` () =
|
12
|
+
let board =
|
13
|
+
[ " B ";
|
14
|
+
" B B ";
|
15
|
+
"B W B";
|
16
|
+
" W W ";
|
17
|
+
" W " ]
|
18
|
+
let position = (0, 1)
|
19
|
+
let expected = Option.Some (Owner.Black, [(0, 0); (0, 1); (1, 0)])
|
20
|
+
territory board position |> should equal expected
|
34
21
|
|
35
22
|
[<Fact(Skip = "Remove to run test")>]
|
36
|
-
let ``
|
37
|
-
let
|
38
|
-
|
23
|
+
let ``White center territory on 5x5 board`` () =
|
24
|
+
let board =
|
25
|
+
[ " B ";
|
26
|
+
" B B ";
|
27
|
+
"B W B";
|
28
|
+
" W W ";
|
29
|
+
" W " ]
|
30
|
+
let position = (2, 3)
|
31
|
+
let expected = Option.Some (Owner.White, [(2, 3)])
|
32
|
+
territory board position |> should equal expected
|
39
33
|
|
40
34
|
[<Fact(Skip = "Remove to run test")>]
|
41
|
-
let ``
|
42
|
-
let
|
43
|
-
|
35
|
+
let ``Open corner territory on 5x5 board`` () =
|
36
|
+
let board =
|
37
|
+
[ " B ";
|
38
|
+
" B B ";
|
39
|
+
"B W B";
|
40
|
+
" W W ";
|
41
|
+
" W " ]
|
42
|
+
let position = (1, 4)
|
43
|
+
let expected = Option.Some (Owner.None, [(0, 3); (0, 4); (1, 4)])
|
44
|
+
territory board position |> should equal expected
|
44
45
|
|
45
46
|
[<Fact(Skip = "Remove to run test")>]
|
46
|
-
let ``
|
47
|
-
|
47
|
+
let ``A stone and not a territory on 5x5 board`` () =
|
48
|
+
let board =
|
49
|
+
[ " B ";
|
50
|
+
" B B ";
|
51
|
+
"B W B";
|
52
|
+
" W W ";
|
53
|
+
" W " ]
|
54
|
+
let position = (1, 1)
|
55
|
+
let expected: (Owner * (int * int) list) option = Option.Some (Owner.None, [])
|
56
|
+
territory board position |> should equal expected
|
48
57
|
|
49
58
|
[<Fact(Skip = "Remove to run test")>]
|
50
|
-
let ``
|
51
|
-
|
59
|
+
let ``Invalid because X is too low for 5x5 board`` () =
|
60
|
+
let board =
|
61
|
+
[ " B ";
|
62
|
+
" B B ";
|
63
|
+
"B W B";
|
64
|
+
" W W ";
|
65
|
+
" W " ]
|
66
|
+
let position = (-1, 1)
|
67
|
+
let expected = Option.None
|
68
|
+
territory board position |> should equal expected
|
52
69
|
|
53
70
|
[<Fact(Skip = "Remove to run test")>]
|
54
|
-
let ``
|
55
|
-
|
71
|
+
let ``Invalid because X is too high for 5x5 board`` () =
|
72
|
+
let board =
|
73
|
+
[ " B ";
|
74
|
+
" B B ";
|
75
|
+
"B W B";
|
76
|
+
" W W ";
|
77
|
+
" W " ]
|
78
|
+
let position = (5, 1)
|
79
|
+
let expected = Option.None
|
80
|
+
territory board position |> should equal expected
|
56
81
|
|
57
82
|
[<Fact(Skip = "Remove to run test")>]
|
58
|
-
let ``
|
59
|
-
let
|
60
|
-
|
83
|
+
let ``Invalid because Y is too low for 5x5 board`` () =
|
84
|
+
let board =
|
85
|
+
[ " B ";
|
86
|
+
" B B ";
|
87
|
+
"B W B";
|
88
|
+
" W W ";
|
89
|
+
" W " ]
|
90
|
+
let position = (1, -1)
|
91
|
+
let expected = Option.None
|
92
|
+
territory board position |> should equal expected
|
61
93
|
|
62
|
-
|
94
|
+
[<Fact(Skip = "Remove to run test")>]
|
95
|
+
let ``Invalid because Y is too high for 5x5 board`` () =
|
96
|
+
let board =
|
97
|
+
[ " B ";
|
98
|
+
" B B ";
|
99
|
+
"B W B";
|
100
|
+
" W W ";
|
101
|
+
" W " ]
|
102
|
+
let position = (1, 5)
|
103
|
+
let expected = Option.None
|
104
|
+
territory board position |> should equal expected
|
63
105
|
|
64
106
|
[<Fact(Skip = "Remove to run test")>]
|
65
|
-
let ``One territory
|
66
|
-
let
|
67
|
-
let expected =
|
107
|
+
let ``One territory is the whole board`` () =
|
108
|
+
let board = [" "]
|
109
|
+
let expected =
|
110
|
+
[ (Owner.Black, []);
|
111
|
+
(Owner.White, []);
|
112
|
+
(Owner.None, [(0, 0)]) ]
|
113
|
+
|> Map.ofList
|
114
|
+
territories board |> should equal expected
|
68
115
|
|
69
|
-
|
116
|
+
[<Fact(Skip = "Remove to run test")>]
|
117
|
+
let ``Two territory rectangular board`` () =
|
118
|
+
let board =
|
119
|
+
[ " BW ";
|
120
|
+
" BW " ]
|
121
|
+
let expected =
|
122
|
+
[ (Owner.Black, [(0, 0); (0, 1)]);
|
123
|
+
(Owner.White, [(3, 0); (3, 1)]);
|
124
|
+
(Owner.None, []) ]
|
125
|
+
|> Map.ofList
|
126
|
+
territories board |> should equal expected
|
70
127
|
|
71
128
|
[<Fact(Skip = "Remove to run test")>]
|
72
|
-
let ``Two
|
73
|
-
let
|
74
|
-
let expected =
|
75
|
-
|
76
|
-
|
129
|
+
let ``Two region rectangular board`` () =
|
130
|
+
let board = [" B "]
|
131
|
+
let expected =
|
132
|
+
[ (Owner.Black, [(0, 0); (2, 0)]);
|
133
|
+
(Owner.White, []);
|
134
|
+
(Owner.None, []) ]
|
135
|
+
|> Map.ofList
|
136
|
+
territories board |> should equal expected
|
77
137
|
|
78
|
-
territories input |> should equal expected
|
@@ -536,6 +536,90 @@ type Gigasecond() =
|
|
536
536
|
|
537
537
|
override __.AdditionalNamespaces = [typeof<DateTime>.Namespace]
|
538
538
|
|
539
|
+
type GoCounting() =
|
540
|
+
inherit GeneratorExercise()
|
541
|
+
|
542
|
+
let renderOwner (value: JToken) =
|
543
|
+
value
|
544
|
+
|> string
|
545
|
+
|> String.toLower
|
546
|
+
|> String.upperCaseFirst
|
547
|
+
|> sprintf "Owner.%s"
|
548
|
+
|
549
|
+
let renderTerritoryPosition (value: JToken) =
|
550
|
+
let arr = value :?> JArray
|
551
|
+
(arr.[0].ToObject<int>(), arr.[1].ToObject<int>())
|
552
|
+
|> formatValue
|
553
|
+
|
554
|
+
let renderTerritory (value: JToken) =
|
555
|
+
value :?> JArray
|
556
|
+
|> Seq.map renderTerritoryPosition
|
557
|
+
|> formatList
|
558
|
+
|
559
|
+
let renderTerritoryWithOwner (value: obj) =
|
560
|
+
let expected = value :?> JObject
|
561
|
+
let owner = expected.["owner"] |> renderOwner
|
562
|
+
let territory = expected.["territory"] |> renderTerritory
|
563
|
+
sprintf "(%s, %s)" owner territory
|
564
|
+
|
565
|
+
let renderExpectedTerritory (value: obj) =
|
566
|
+
match Option.ofNonError value with
|
567
|
+
| None -> "Option.None"
|
568
|
+
| Some expected -> expected |> renderTerritoryWithOwner |> sprintf "Option.Some %s"
|
569
|
+
|
570
|
+
let renderExpectedTerritories (value: obj) =
|
571
|
+
let expected = value :?> JObject
|
572
|
+
let black = sprintf "(Owner.Black, %s)" (expected.["territoryBlack"] |> renderTerritory)
|
573
|
+
let white = sprintf "(Owner.White, %s)" (expected.["territoryWhite"] |> renderTerritory)
|
574
|
+
let none = sprintf "(Owner.None, %s)" (expected.["territoryNone"] |> renderTerritory)
|
575
|
+
|
576
|
+
let formattedList = formatMultiLineList [black; white; none]
|
577
|
+
sprintf "%s\n%s" formattedList (indent 2 "|> Map.ofList")
|
578
|
+
|
579
|
+
let territoryPosition (input: Map<string, obj>) =
|
580
|
+
let valueToInt key = input |> Map.find key |> string |> int
|
581
|
+
(valueToInt "x", valueToInt "y") |> box
|
582
|
+
|
583
|
+
let mapTerritoryInput (input: Map<string, obj>) =
|
584
|
+
input
|
585
|
+
|> Map.remove "x"
|
586
|
+
|> Map.remove "y"
|
587
|
+
|> Map.add "position" (territoryPosition input)
|
588
|
+
|
589
|
+
override __.MapCanonicalDataCaseInput (canonicalDataCase, input) =
|
590
|
+
match canonicalDataCase.Property with
|
591
|
+
| "territory" -> mapTerritoryInput input
|
592
|
+
| _ -> base.MapCanonicalDataCaseInput(canonicalDataCase, input)
|
593
|
+
|
594
|
+
override __.RenderInput (canonicalDataCase, key, value) =
|
595
|
+
match key with
|
596
|
+
| "board" ->
|
597
|
+
value :?> JArray
|
598
|
+
|> Seq.map formatValue
|
599
|
+
|> formatMultiLineList
|
600
|
+
| _ ->
|
601
|
+
base.RenderInput (canonicalDataCase, key, value)
|
602
|
+
|
603
|
+
override __.RenderExpected (canonicalDataCase, key, value) =
|
604
|
+
match canonicalDataCase.Property with
|
605
|
+
| "territory" -> renderExpectedTerritory value
|
606
|
+
| "territories" -> renderExpectedTerritories value
|
607
|
+
| _ -> base.RenderExpected(canonicalDataCase, key, value)
|
608
|
+
|
609
|
+
override __.PropertiesWithIdentifier canonicalDataCase = base.Properties canonicalDataCase
|
610
|
+
|
611
|
+
override __.IdentifierTypeAnnotation (canonicalDataCase, key, value) =
|
612
|
+
match canonicalDataCase.Property, key with
|
613
|
+
| "territory", "expected" ->
|
614
|
+
match Option.ofNonError value with
|
615
|
+
| None -> None
|
616
|
+
| Some _ ->
|
617
|
+
if (value :?> JObject).["territory"] :?> JArray |> Seq.isEmpty then
|
618
|
+
Some "(Owner * (int * int) list) option"
|
619
|
+
else
|
620
|
+
None
|
621
|
+
| _ -> None
|
622
|
+
|
539
623
|
type Grains() =
|
540
624
|
inherit GeneratorExercise()
|
541
625
|
|
data/tracks/java/config.json
CHANGED
@@ -638,19 +638,6 @@
|
|
638
638
|
"unlocked_by": "rotational-cipher",
|
639
639
|
"uuid": "d36ce010-210f-4e9a-9d6c-cb933e0a59af"
|
640
640
|
},
|
641
|
-
{
|
642
|
-
"core": false,
|
643
|
-
"difficulty": 5,
|
644
|
-
"slug": "two-bucket",
|
645
|
-
"topics": [
|
646
|
-
"algorithms",
|
647
|
-
"loops",
|
648
|
-
"conditionals",
|
649
|
-
"mathematics"
|
650
|
-
],
|
651
|
-
"unlocked_by": "triangle",
|
652
|
-
"uuid": "210bf628-b385-443b-8329-3483cc6e8d7e"
|
653
|
-
},
|
654
641
|
{
|
655
642
|
"core": false,
|
656
643
|
"difficulty": 6,
|
@@ -937,6 +924,19 @@
|
|
937
924
|
"unlocked_by": "rotational-cipher",
|
938
925
|
"uuid": "6e4ad4ed-cc02-4132-973d-b9163ba0ea3d"
|
939
926
|
},
|
927
|
+
{
|
928
|
+
"core": false,
|
929
|
+
"difficulty": 7,
|
930
|
+
"slug": "two-bucket",
|
931
|
+
"topics": [
|
932
|
+
"algorithms",
|
933
|
+
"loops",
|
934
|
+
"conditionals",
|
935
|
+
"mathematics"
|
936
|
+
],
|
937
|
+
"unlocked_by": "triangle",
|
938
|
+
"uuid": "210bf628-b385-443b-8329-3483cc6e8d7e"
|
939
|
+
},
|
940
940
|
{
|
941
941
|
"core": false,
|
942
942
|
"difficulty": 7,
|
@@ -284,6 +284,18 @@
|
|
284
284
|
"maybe",
|
285
285
|
"strings"
|
286
286
|
]
|
287
|
+
},
|
288
|
+
{
|
289
|
+
"uuid": "09a9ab8e-acaf-4f3d-96ff-789321a53785",
|
290
|
+
"slug": "phone-number",
|
291
|
+
"core": false,
|
292
|
+
"unlocked_by": null,
|
293
|
+
"difficulty": 1,
|
294
|
+
"topics": [
|
295
|
+
"pattern_matching",
|
296
|
+
"conditionals",
|
297
|
+
"strings"
|
298
|
+
]
|
287
299
|
}
|
288
300
|
],
|
289
301
|
"foregone": [
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# Phone Number
|
2
|
+
|
3
|
+
Clean up user-entered phone numbers so that they can be sent SMS messages.
|
4
|
+
|
5
|
+
The **North American Numbering Plan (NANP)** is a telephone numbering system used by many countries in North America like the United States, Canada or Bermuda. All NANP-countries share the same international country code: `1`.
|
6
|
+
|
7
|
+
NANP numbers are ten-digit numbers consisting of a three-digit Numbering Plan Area code, commonly known as *area code*, followed by a seven-digit local number. The first three digits of the local number represent the *exchange code*, followed by the unique four-digit number which is the *subscriber number*.
|
8
|
+
|
9
|
+
The format is usually represented as
|
10
|
+
|
11
|
+
```text
|
12
|
+
(NXX)-NXX-XXXX
|
13
|
+
```
|
14
|
+
|
15
|
+
where `N` is any digit from 2 through 9 and `X` is any digit from 0 through 9.
|
16
|
+
|
17
|
+
Your task is to clean up differently formatted telephone numbers by removing punctuation and the country code (1) if present.
|
18
|
+
|
19
|
+
For example, the inputs
|
20
|
+
- `+1 (613)-995-0253`
|
21
|
+
- `613-995-0253`
|
22
|
+
- `1 613 995 0253`
|
23
|
+
- `613.995.0253`
|
24
|
+
|
25
|
+
should all produce the output
|
26
|
+
|
27
|
+
`6139950253`
|
28
|
+
|
29
|
+
**Note:** As this exercise only deals with telephone numbers used in NANP-countries, only 1 is considered a valid country code.
|
30
|
+
|
31
|
+
## Source
|
32
|
+
|
33
|
+
Event Manager by JumpstartLab [http://tutorials.jumpstartlab.com/projects/eventmanager.html](http://tutorials.jumpstartlab.com/projects/eventmanager.html)
|
34
|
+
|
35
|
+
## Submitting Incomplete Solutions
|
36
|
+
It's possible to submit an incomplete solution so you can see how others have completed the exercise.
|
@@ -0,0 +1,26 @@
|
|
1
|
+
{
|
2
|
+
"name": "phone-number",
|
3
|
+
"ignore": [
|
4
|
+
"**/.*",
|
5
|
+
"node_modules",
|
6
|
+
"bower_components",
|
7
|
+
"output"
|
8
|
+
],
|
9
|
+
"dependencies": {
|
10
|
+
"purescript-console": "^3.0.0",
|
11
|
+
"purescript-datetime": "^3.4.0",
|
12
|
+
"purescript-either": "^3.1.0",
|
13
|
+
"purescript-enums": "^3.2.1",
|
14
|
+
"purescript-integers": "^3.1.0",
|
15
|
+
"purescript-lists": "^4.10.0",
|
16
|
+
"purescript-maps": "^3.5.2",
|
17
|
+
"purescript-prelude": "^3.1.0",
|
18
|
+
"purescript-sets": "^3.0.0",
|
19
|
+
"purescript-strings": "^3.3.1",
|
20
|
+
"purescript-unicode": "^3.0.1"
|
21
|
+
},
|
22
|
+
"devDependencies": {
|
23
|
+
"purescript-psci-support": "^3.0.0",
|
24
|
+
"purescript-test-unit": "^13.0.0"
|
25
|
+
}
|
26
|
+
}
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module PhoneNumber
|
2
|
+
( phoneNumber
|
3
|
+
)
|
4
|
+
where
|
5
|
+
|
6
|
+
import Prelude ((==), (<), (>>=), (&&), ($), otherwise)
|
7
|
+
import Data.Char.Unicode (isDigit)
|
8
|
+
import Data.Array (filter, head, tail, length, (!!))
|
9
|
+
import Data.String (toCharArray, fromCharArray)
|
10
|
+
import Data.Maybe (Maybe(..), fromMaybe)
|
11
|
+
|
12
|
+
clean :: String -> Maybe (Array Char)
|
13
|
+
clean input = go where
|
14
|
+
go
|
15
|
+
| len == 10 = Just digits
|
16
|
+
| len == 11 && head digits == Just '1' = tail digits
|
17
|
+
| otherwise = Nothing
|
18
|
+
digits = filter isDigit $ toCharArray input
|
19
|
+
len = length digits
|
20
|
+
|
21
|
+
check:: Array Char -> Maybe String
|
22
|
+
check input
|
23
|
+
| input !! 0 < Just '2' = Nothing
|
24
|
+
| input !! 3 < Just '2' = Nothing
|
25
|
+
| otherwise = Just $ fromCharArray input
|
26
|
+
|
27
|
+
|
28
|
+
phoneNumber :: String -> String
|
29
|
+
phoneNumber input = fromMaybe "None" (clean input >>= check)
|
30
|
+
|
@@ -0,0 +1,50 @@
|
|
1
|
+
module Test.Main where
|
2
|
+
|
3
|
+
import Prelude
|
4
|
+
import Control.Monad.Eff (Eff)
|
5
|
+
import Control.Monad.Aff.AVar (AVAR)
|
6
|
+
import Control.Monad.Eff.Console (CONSOLE)
|
7
|
+
import Test.Unit (TestSuite, suite, test)
|
8
|
+
import Test.Unit.Console (TESTOUTPUT)
|
9
|
+
import Test.Unit.Main (runTest)
|
10
|
+
import Test.Unit.Assert as Assert
|
11
|
+
import PhoneNumber (phoneNumber)
|
12
|
+
|
13
|
+
main :: forall eff
|
14
|
+
. Eff ( avar :: AVAR
|
15
|
+
, console :: CONSOLE
|
16
|
+
, testOutput :: TESTOUTPUT
|
17
|
+
| eff
|
18
|
+
)
|
19
|
+
Unit
|
20
|
+
main = runTest suites
|
21
|
+
|
22
|
+
suites :: forall e. TestSuite e
|
23
|
+
suites = do
|
24
|
+
suite "PhoneNumber.phoneNumber" do
|
25
|
+
test "cleans the number" do
|
26
|
+
Assert.equal "2234567890" $ phoneNumber "(223) 456-7890"
|
27
|
+
test "cleans numbers with dots" do
|
28
|
+
Assert.equal "2234567890" $ phoneNumber "223.456.7890"
|
29
|
+
test "cleans numbers with multiple spaces" do
|
30
|
+
Assert.equal "2234567890" $ phoneNumber "223 456 7890 "
|
31
|
+
test "invalid when 9 digits" do
|
32
|
+
Assert.equal "None" $ phoneNumber "123456789"
|
33
|
+
test "invalid when 11 digits does not start with a 1" do
|
34
|
+
Assert.equal "None" $ phoneNumber "22234567890"
|
35
|
+
test "valid when 11 digits and starting with 1" do
|
36
|
+
Assert.equal "2234567890" $ phoneNumber "12234567890"
|
37
|
+
test "valid when 11 digits and starting with 1 even with punctuation" do
|
38
|
+
Assert.equal "2234567890" $ phoneNumber "+1 (223) 456-7890"
|
39
|
+
test "invalid when more than 11 digits" do
|
40
|
+
Assert.equal "None" $ phoneNumber "321234567890"
|
41
|
+
test "invalid with letters" do
|
42
|
+
Assert.equal "None" $ phoneNumber "123-abc-7890"
|
43
|
+
test "invalid with punctuations" do
|
44
|
+
Assert.equal "None" $ phoneNumber "123-@:!-7890"
|
45
|
+
test "invalid if area code does not start with 2-9" do
|
46
|
+
Assert.equal "None" $ phoneNumber "(123) 456-7890"
|
47
|
+
test "invalid if exchange code does not start with 2-9" do
|
48
|
+
Assert.equal "None" $ phoneNumber "(223) 056-7890"
|
49
|
+
|
50
|
+
|