tracks/perl6/exercises/hamming/hamming.t in trackler-2.2.1.100 vs tracks/perl6/exercises/hamming/hamming.t in trackler-2.2.1.101
- old
+ new
@@ -15,22 +15,21 @@
}
my $c-data = from-json $=pod.pop.contents;
for $c-data<cases>.values {
if .<expected><error> {
- throws-like {hamming-distance(|.<strand1 strand2>)}, Exception, .<description>;
+ throws-like {hamming-distance(|.<input><strand1 strand2>)}, Exception, .<description>;
} else {
- is hamming-distance(|.<strand1 strand2>), |.<expected description>;
+ is hamming-distance(|.<input><strand1 strand2>), |.<expected description>;
}
}
=head2 Canonical Data
=begin code
-
{
"exercise": "hamming",
-"version": "2.0.1",
+"version": "2.1.0",
"comments": [
"Language implementations vary on the issue of unequal length strands.",
"A language may elect to simplify this task by only presenting equal",
"length test cases. For languages handling unequal length strands as",
"error condition, unequal length test cases are included here and are",
@@ -43,111 +42,140 @@
],
"cases": [
{
"description": "empty strands",
"property": "distance",
- "strand1": "",
- "strand2": "",
+ "input": {
+ "strand1": "",
+ "strand2": ""
+ },
"expected": 0
},
{
"description": "identical strands",
"property": "distance",
- "strand1": "A",
- "strand2": "A",
+ "input": {
+ "strand1": "A",
+ "strand2": "A"
+ },
"expected": 0
},
{
"description": "long identical strands",
"property": "distance",
- "strand1": "GGACTGA",
- "strand2": "GGACTGA",
+ "input": {
+ "strand1": "GGACTGA",
+ "strand2": "GGACTGA"
+ },
"expected": 0
},
{
"description": "complete distance in single nucleotide strands",
"property": "distance",
- "strand1": "A",
- "strand2": "G",
+ "input": {
+ "strand1": "A",
+ "strand2": "G"
+ },
"expected": 1
},
{
"description": "complete distance in small strands",
"property": "distance",
- "strand1": "AG",
- "strand2": "CT",
+ "input": {
+ "strand1": "AG",
+ "strand2": "CT"
+ },
"expected": 2
},
{
"description": "small distance in small strands",
"property": "distance",
- "strand1": "AT",
- "strand2": "CT",
+ "input": {
+ "strand1": "AT",
+ "strand2": "CT"
+ },
"expected": 1
},
{
"description": "small distance",
"property": "distance",
- "strand1": "GGACG",
- "strand2": "GGTCG",
+ "input": {
+ "strand1": "GGACG",
+ "strand2": "GGTCG"
+ },
"expected": 1
},
{
"description": "small distance in long strands",
"property": "distance",
- "strand1": "ACCAGGG",
- "strand2": "ACTATGG",
+ "input": {
+ "strand1": "ACCAGGG",
+ "strand2": "ACTATGG"
+ },
"expected": 2
},
{
"description": "non-unique character in first strand",
"property": "distance",
- "strand1": "AAG",
- "strand2": "AAA",
+ "input": {
+ "strand1": "AAG",
+ "strand2": "AAA"
+ },
"expected": 1
},
{
"description": "non-unique character in second strand",
"property": "distance",
- "strand1": "AAA",
- "strand2": "AAG",
+ "input": {
+ "strand1": "AAA",
+ "strand2": "AAG"
+ },
"expected": 1
},
{
"description": "same nucleotides in different positions",
"property": "distance",
- "strand1": "TAG",
- "strand2": "GAT",
+ "input": {
+ "strand1": "TAG",
+ "strand2": "GAT"
+ },
"expected": 2
},
{
"description": "large distance",
"property": "distance",
- "strand1": "GATACA",
- "strand2": "GCATAA",
+ "input": {
+ "strand1": "GATACA",
+ "strand2": "GCATAA"
+ },
"expected": 4
},
{
"description": "large distance in off-by-one strand",
"property": "distance",
- "strand1": "GGACGGATTCTG",
- "strand2": "AGGACGGATTCT",
+ "input": {
+ "strand1": "GGACGGATTCTG",
+ "strand2": "AGGACGGATTCT"
+ },
"expected": 9
},
{
"description": "disallow first strand longer",
"property": "distance",
- "strand1": "AATG",
- "strand2": "AAA",
+ "input": {
+ "strand1": "AATG",
+ "strand2": "AAA"
+ },
"expected": {"error": "left and right strands must be of equal length"}
},
{
"description": "disallow second strand longer",
"property": "distance",
- "strand1": "ATA",
- "strand2": "AGTG",
+ "input": {
+ "strand1": "ATA",
+ "strand2": "AGTG"
+ },
"expected": {"error": "left and right strands must be of equal length"}
}
]
}
-
=end code