From 026ca2b808ded73f23db1c681ee5933d9dccd9dd Mon Sep 17 00:00:00 2001
From: Eric Willigers <keiravillekode@gmail.com>
Date: Tue, 19 Dec 2023 18:58:10 +1100
Subject: [PATCH] Sync phone-number exercise

---
 .../phone-number/.docs/instructions.md        | 10 ++++---
 .../practice/phone-number/.meta/tests.toml    | 20 +++++++++++++
 exercises/practice/phone-number/test.sml      | 30 +++++++++++++++----
 3 files changed, 50 insertions(+), 10 deletions(-)

diff --git a/exercises/practice/phone-number/.docs/instructions.md b/exercises/practice/phone-number/.docs/instructions.md
index 6d3275cd..62ba48e9 100644
--- a/exercises/practice/phone-number/.docs/instructions.md
+++ b/exercises/practice/phone-number/.docs/instructions.md
@@ -5,18 +5,20 @@ Clean up user-entered phone numbers so that they can be sent SMS messages.
 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`.
 
-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*.
+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_.
 
 The format is usually represented as
 
 ```text
-(NXX)-NXX-XXXX
+NXX NXX-XXXX
 ```
 
 where `N` is any digit from 2 through 9 and `X` is any digit from 0 through 9.
 
-Your task is to clean up differently formatted telephone numbers by removing punctuation and the country code (1) if present.
+Sometimes they also have the country code (represented as `1` or `+1`) prefixed.
+
+Your task is to clean up differently formatted telephone numbers by removing punctuation and the country code if present.
 
 For example, the inputs
 
diff --git a/exercises/practice/phone-number/.meta/tests.toml b/exercises/practice/phone-number/.meta/tests.toml
index a0e16ebf..24dbf07a 100644
--- a/exercises/practice/phone-number/.meta/tests.toml
+++ b/exercises/practice/phone-number/.meta/tests.toml
@@ -20,6 +20,11 @@ description = "cleans numbers with multiple spaces"
 
 [598d8432-0659-4019-a78b-1c6a73691d21]
 description = "invalid when 9 digits"
+include = false
+
+[2de74156-f646-42b5-8638-0ef1d8b58bc2]
+description = "invalid when 9 digits"
+reimplements = "598d8432-0659-4019-a78b-1c6a73691d21"
 
 [57061c72-07b5-431f-9766-d97da7c4399d]
 description = "invalid when 11 digits does not start with a 1"
@@ -32,12 +37,27 @@ description = "valid when 11 digits and starting with 1 even with punctuation"
 
 [c6a5f007-895a-4fc5-90bc-a7e70f9b5cad]
 description = "invalid when more than 11 digits"
+include = false
+
+[4a1509b7-8953-4eec-981b-c483358ff531]
+description = "invalid when more than 11 digits"
+reimplements = "c6a5f007-895a-4fc5-90bc-a7e70f9b5cad"
 
 [63f38f37-53f6-4a5f-bd86-e9b404f10a60]
 description = "invalid with letters"
+include = false
+
+[eb8a1fc0-64e5-46d3-b0c6-33184208e28a]
+description = "invalid with letters"
+reimplements = "63f38f37-53f6-4a5f-bd86-e9b404f10a60"
 
 [4bd97d90-52fd-45d3-b0db-06ab95b1244e]
 description = "invalid with punctuations"
+include = false
+
+[065f6363-8394-4759-b080-e6c8c351dd1f]
+description = "invalid with punctuations"
+reimplements = "4bd97d90-52fd-45d3-b0db-06ab95b1244e"
 
 [d77d07f8-873c-4b17-8978-5f66139bf7d7]
 description = "invalid if area code starts with 0"
diff --git a/exercises/practice/phone-number/test.sml b/exercises/practice/phone-number/test.sml
index e8415218..9897cdd2 100644
--- a/exercises/practice/phone-number/test.sml
+++ b/exercises/practice/phone-number/test.sml
@@ -1,4 +1,4 @@
-(* version 1.2.0 *)
+(* version 1.3.0 *)
 
 use "testlib.sml";
 use "phone-number.sml";
@@ -34,16 +34,34 @@ val testsuite =
         (fn _ => clean ("321234567890") |> Expect.equalTo NONE),
 
       test "invalid with letters"
-        (fn _ => clean ("123-abc-7890") |> Expect.equalTo NONE),
+        (fn _ => clean ("523-abc-7890") |> Expect.equalTo NONE),
 
       test "invalid with punctuations"
-        (fn _ => clean ("123-@:!-7890") |> Expect.equalTo NONE),
+        (fn _ => clean ("523-@:!-7890") |> Expect.equalTo NONE),
 
-      test "invalid if area code does not start with 2-9"
+      test "invalid if area code starts with 0"
+        (fn _ => clean ("(023) 456-7890") |> Expect.equalTo NONE),
+
+      test "invalid if area code starts with 1"
         (fn _ => clean ("(123) 456-7890") |> Expect.equalTo NONE),
 
-      test "invalid if exchange code does not start with 2-9"
-        (fn _ => clean ("(223) 056-7890") |> Expect.equalTo NONE)
+      test "invalid if exchange code starts with 0"
+        (fn _ => clean ("(223) 056-7890") |> Expect.equalTo NONE),
+
+      test "invalid if exchange code starts with 1"
+        (fn _ => clean ("(223) 156-7890") |> Expect.equalTo NONE),
+
+      test "invalid if area code starts with 0 on valid 11-digit number"
+        (fn _ => clean ("1 (023) 456-7890") |> Expect.equalTo NONE),
+
+      test "invalid if area code starts with 1 on valid 11-digit number"
+        (fn _ => clean ("1 (123) 456-7890") |> Expect.equalTo NONE),
+
+      test "invalid if exchange code starts with 0 on valid 11-digit number"
+        (fn _ => clean ("1 (223) 056-7890") |> Expect.equalTo NONE),
+
+      test "invalid if exchange code starts with 1 on valid 11-digit number"
+        (fn _ => clean ("1 (223) 156-7890") |> Expect.equalTo NONE)
     ]
   ]