From b06325e743764cda5620134237618a007f805a0a Mon Sep 17 00:00:00 2001 From: Natanael Sirqueira Date: Wed, 1 Mar 2023 19:28:58 -0400 Subject: [PATCH 1/5] Rational Numbers: add error test case to expreal property --- .../rational-numbers/canonical-data.json | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/exercises/rational-numbers/canonical-data.json b/exercises/rational-numbers/canonical-data.json index 0ee600acd9..7decf282ec 100644 --- a/exercises/rational-numbers/canonical-data.json +++ b/exercises/rational-numbers/canonical-data.json @@ -400,6 +400,28 @@ "r": [0, 1] }, "expected": 1.0 + }, + { + "uuid": "da137f1c-fc94-4035-9813-94f5152a1102", + "description": "Raise a negative real number to a rational number with an even numerator", + "property": "expreal", + "input": { + "x": -1, + "r": [2, 2] + }, + "expected": 1.0 + }, + { + "uuid": "f3734f78-91b2-4e59-905e-8c61dbf34f39", + "description": "Fails with a negative base if the numerator of the exponent is odd", + "property": "expreal", + "input": { + "x": -1, + "r": [1, 2] + }, + "expected": { + "error": "impossible operation" + } } ] }, From 1f671866e51a6619a31dd807c66ff7cc627fbb0c Mon Sep 17 00:00:00 2001 From: Natanael Sirqueira Date: Wed, 1 Mar 2023 19:40:30 -0400 Subject: [PATCH 2/5] Add better error message --- exercises/rational-numbers/canonical-data.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/exercises/rational-numbers/canonical-data.json b/exercises/rational-numbers/canonical-data.json index 7decf282ec..90518e9246 100644 --- a/exercises/rational-numbers/canonical-data.json +++ b/exercises/rational-numbers/canonical-data.json @@ -413,14 +413,14 @@ }, { "uuid": "f3734f78-91b2-4e59-905e-8c61dbf34f39", - "description": "Fails with a negative base if the numerator of the exponent is odd", + "description": "Fails with a negative real number if the numerator of the rational number is odd", "property": "expreal", "input": { "x": -1, "r": [1, 2] }, "expected": { - "error": "impossible operation" + "error": "impossible to raise a negative base to an exponent with an odd numerator" } } ] From aa6810424a419c84c3ca4e7ab170a949611b961b Mon Sep 17 00:00:00 2001 From: Natanael Sirqueira Date: Wed, 1 Mar 2023 22:41:09 -0400 Subject: [PATCH 3/5] Review fixes --- exercises/rational-numbers/canonical-data.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/exercises/rational-numbers/canonical-data.json b/exercises/rational-numbers/canonical-data.json index 90518e9246..5df8ae46e7 100644 --- a/exercises/rational-numbers/canonical-data.json +++ b/exercises/rational-numbers/canonical-data.json @@ -403,24 +403,24 @@ }, { "uuid": "da137f1c-fc94-4035-9813-94f5152a1102", - "description": "Raise a negative real number to a rational number with an even numerator", + "description": "Raise a negative real number to a rational number", "property": "expreal", "input": { "x": -1, "r": [2, 2] }, - "expected": 1.0 + "expected": -1.0 }, { "uuid": "f3734f78-91b2-4e59-905e-8c61dbf34f39", - "description": "Fails with a negative real number if the numerator of the rational number is odd", + "description": "Fails with a negative real number if the denominator of the reduced rational number is even", "property": "expreal", "input": { "x": -1, - "r": [1, 2] + "r": [2, 4] }, "expected": { - "error": "impossible to raise a negative base to an exponent with an odd numerator" + "error": "the result of this operation is a complex number" } } ] From 51304e8137b7c6002268d52481dca1c7564a0ba2 Mon Sep 17 00:00:00 2001 From: Natanael Sirqueira Date: Thu, 2 Mar 2023 08:00:20 -0400 Subject: [PATCH 4/5] Use reduced rational number as input --- exercises/rational-numbers/canonical-data.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/exercises/rational-numbers/canonical-data.json b/exercises/rational-numbers/canonical-data.json index 5df8ae46e7..389b1880ee 100644 --- a/exercises/rational-numbers/canonical-data.json +++ b/exercises/rational-numbers/canonical-data.json @@ -407,7 +407,7 @@ "property": "expreal", "input": { "x": -1, - "r": [2, 2] + "r": [1, 1] }, "expected": -1.0 }, @@ -417,7 +417,7 @@ "property": "expreal", "input": { "x": -1, - "r": [2, 4] + "r": [1, 2] }, "expected": { "error": "the result of this operation is a complex number" From 9a2b1cb7f268ea47c85538985e3f79ec2f08aaaf Mon Sep 17 00:00:00 2001 From: Natanael Sirqueira Date: Thu, 2 Mar 2023 08:21:30 -0400 Subject: [PATCH 5/5] Add case for when the rational number has not been reduced --- exercises/rational-numbers/canonical-data.json | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/exercises/rational-numbers/canonical-data.json b/exercises/rational-numbers/canonical-data.json index 389b1880ee..82335b8d12 100644 --- a/exercises/rational-numbers/canonical-data.json +++ b/exercises/rational-numbers/canonical-data.json @@ -403,7 +403,7 @@ }, { "uuid": "da137f1c-fc94-4035-9813-94f5152a1102", - "description": "Raise a negative real number to a rational number", + "description": "Raise a negative real number to a rational number that has been reduced", "property": "expreal", "input": { "x": -1, @@ -411,6 +411,16 @@ }, "expected": -1.0 }, + { + "uuid": "9abd9332-eeab-4139-afa2-2f82efdae421", + "description": "Raise a negative real number to a rational number that has not been reduced", + "property": "expreal", + "input": { + "x": -1, + "r": [2, 2] + }, + "expected": -1.0 + }, { "uuid": "f3734f78-91b2-4e59-905e-8c61dbf34f39", "description": "Fails with a negative real number if the denominator of the reduced rational number is even",