trackler 2.0.3.2 → 2.0.3.3
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/tracks/c/config.json +10 -0
- data/tracks/c/exercises/robot-simulator/makefile +16 -0
- data/tracks/c/exercises/robot-simulator/src/example.c +74 -0
- data/tracks/c/exercises/robot-simulator/src/robot_simulator.h +41 -0
- data/tracks/c/exercises/robot-simulator/test/test_robot_simulator.c +165 -0
- data/tracks/c/exercises/robot-simulator/test/vendor/unity.c +1300 -0
- data/tracks/c/exercises/robot-simulator/test/vendor/unity.h +274 -0
- data/tracks/c/exercises/robot-simulator/test/vendor/unity_internals.h +701 -0
- data/tracks/ecmascript/exercises/rna-transcription/example.js +9 -2
- data/tracks/ecmascript/exercises/rna-transcription/rna-transcription.spec.js +18 -0
- data/tracks/go/exercises/hello-world/example.go +4 -2
- data/tracks/go/exercises/hello-world/hello_test.go +4 -4
- data/tracks/go/exercises/hello-world/hello_world.go +6 -6
- data/tracks/groovy/config.json +5 -0
- data/tracks/groovy/exercises/phone-number/Example.groovy +20 -0
- data/tracks/groovy/exercises/phone-number/PhoneNumberSpec.groovy +75 -0
- data/tracks/haskell/exercises/difference-of-squares/test/Tests.hs +2 -0
- data/tracks/java/config.json +13 -1
- data/tracks/java/exercises/all-your-base/build.gradle +17 -0
- data/tracks/java/exercises/all-your-base/src/example/java/BaseConverter.java +80 -0
- data/tracks/java/exercises/all-your-base/src/main/java/BaseConverter.java +5 -0
- data/tracks/java/exercises/all-your-base/src/test/java/BaseConverterTest.java +256 -0
- data/tracks/java/exercises/binary-search/build.gradle +17 -0
- data/tracks/java/exercises/binary-search/src/example/java/BinarySearch.java +40 -0
- data/tracks/java/exercises/binary-search/src/main/java/.keep +0 -0
- data/tracks/java/exercises/binary-search/src/main/java/BinarySearch.java +4 -0
- data/tracks/java/exercises/binary-search/src/test/java/.keep +0 -0
- data/tracks/java/exercises/binary-search/src/test/java/BinarySearchTest.java +136 -0
- data/tracks/java/exercises/settings.gradle +1 -0
- data/tracks/lua/config.json +16 -0
- data/tracks/lua/exercises/say/example.lua +92 -0
- data/tracks/lua/exercises/say/say_spec.lua +105 -0
- data/tracks/lua/exercises/secret-handshake/example.lua +17 -0
- data/tracks/lua/exercises/secret-handshake/secret-handshake_spec.lua +38 -0
- data/tracks/ocaml/config.json +10 -1
- data/tracks/ocaml/exercises/bracket-push/.merlin +3 -0
- data/tracks/ocaml/exercises/bracket-push/Makefile +11 -0
- data/tracks/ocaml/exercises/bracket-push/bracket_push.mli +3 -0
- data/tracks/ocaml/exercises/bracket-push/example.ml +40 -0
- data/tracks/ocaml/exercises/bracket-push/test.ml +38 -0
- data/tracks/ocaml/exercises/leap/test.ml +7 -7
- data/tracks/ocaml/tools/test-generator/Makefile +2 -2
- data/tracks/ocaml/tools/test-generator/interfaces/codegen.mli +2 -2
- data/tracks/ocaml/tools/test-generator/interfaces/{test_generator.mli → controller.mli} +0 -0
- data/tracks/ocaml/tools/test-generator/interfaces/parser.mli +7 -1
- data/tracks/ocaml/tools/test-generator/interfaces/special_cases.mli +2 -2
- data/tracks/ocaml/tools/test-generator/interfaces/utils.mli +4 -0
- data/tracks/ocaml/tools/test-generator/src/codegen.ml +9 -5
- data/tracks/ocaml/tools/test-generator/src/{test_generator.ml → controller.ml} +24 -15
- data/tracks/ocaml/tools/test-generator/src/model.ml +6 -0
- data/tracks/ocaml/tools/test-generator/src/parser.ml +34 -7
- data/tracks/ocaml/tools/test-generator/src/special_cases.ml +11 -4
- data/tracks/ocaml/tools/test-generator/src/template.ml +49 -6
- data/tracks/ocaml/tools/test-generator/src/test_gen.ml +1 -1
- data/tracks/ocaml/tools/test-generator/src/utils.ml +6 -0
- data/tracks/ocaml/tools/test-generator/templates/anagram/template.ml +2 -2
- data/tracks/ocaml/tools/test-generator/templates/bob/template.ml +2 -2
- data/tracks/ocaml/tools/test-generator/templates/bracket-push/template.ml +16 -0
- data/tracks/ocaml/tools/test-generator/templates/difference-of-squares/template.ml +19 -0
- data/tracks/ocaml/tools/test-generator/templates/hamming/template.ml +2 -2
- data/tracks/ocaml/tools/test-generator/templates/hello-world/template.ml +2 -2
- data/tracks/ocaml/tools/test-generator/templates/leap/template.ml +2 -2
- data/tracks/ocaml/tools/test-generator/templates/raindrops/template.ml +2 -2
- data/tracks/ocaml/tools/test-generator/templates/say/template.ml +3 -3
- data/tracks/ocaml/tools/test-generator/templates/word-count/template.ml +2 -2
- data/tracks/ocaml/tools/test-generator/test/all_tests.ml +3 -1
- data/tracks/ocaml/tools/test-generator/test/codegen_test.ml +7 -7
- data/tracks/ocaml/tools/test-generator/test/difference_of_squares.json +67 -0
- data/tracks/ocaml/tools/test-generator/test/hello_world.json +23 -0
- data/tracks/ocaml/tools/test-generator/test/parser_test.ml +30 -12
- data/tracks/ocaml/tools/test-generator/test/sample-suite-template.txt +16 -0
- data/tracks/ocaml/tools/test-generator/test/sample_template.txt +2 -2
- data/tracks/ocaml/tools/test-generator/test/special_cases_test.ml +1 -1
- data/tracks/ocaml/tools/test-generator/test/template_test.ml +40 -6
- data/tracks/perl6/.travis.yml +3 -0
- data/tracks/perl6/docs/RESOURCES.md +1 -1
- data/tracks/perl6/exercises/accumulate/accumulate.t +3 -7
- data/tracks/perl6/exercises/anagram/anagram.t +3 -7
- data/tracks/perl6/exercises/binary/binary.t +3 -7
- data/tracks/perl6/exercises/bob/bob.t +4 -8
- data/tracks/perl6/exercises/grains/grains.t +3 -7
- data/tracks/perl6/exercises/leap/leap.t +3 -7
- data/tracks/perl6/exercises/rna-transcription/rna_transcription.t +4 -8
- data/tracks/perl6/exercises/robot-name/robot.t +4 -8
- data/tracks/perl6/exercises/scrabble-score/scrabble_score.t +3 -7
- data/tracks/perl6/exercises/word-count/word_count.t +3 -8
- data/tracks/r/config.json +10 -0
- data/tracks/r/docs/ABOUT.md +14 -0
- data/tracks/r/exercises/difference-of-squares/difference-of-squares.R +5 -0
- data/tracks/r/exercises/difference-of-squares/example.R +6 -0
- data/tracks/r/exercises/difference-of-squares/test_difference-of-squares.R +23 -0
- data/tracks/r/exercises/hamming/example.R +8 -0
- data/tracks/r/exercises/hamming/hamming.R +4 -0
- data/tracks/r/exercises/hamming/test_hamming.R +87 -0
- data/tracks/ruby/exercises/binary/.version +1 -1
- data/tracks/ruby/exercises/binary/binary_test.rb +17 -19
- data/tracks/ruby/exercises/binary/example.rb +13 -13
- data/tracks/ruby/exercises/isogram/.version +1 -1
- data/tracks/ruby/exercises/isogram/example.rb +1 -1
- data/tracks/ruby/exercises/isogram/isogram_test.rb +16 -30
- data/tracks/ruby/lib/binary_cases.rb +2 -3
- data/tracks/ruby/lib/isogram_cases.rb +1 -5
- data/tracks/scala/exercises/phone-number/HINTS.md +9 -0
- metadata +45 -4
@@ -0,0 +1,16 @@
|
|
1
|
+
open Core.Std
|
2
|
+
open OUnit2
|
3
|
+
open Difference_of_squares
|
4
|
+
|
5
|
+
let ae exp got _test_ctxt = assert_equal exp got
|
6
|
+
|
7
|
+
let (* SUITE *)$(suite_name)_tests = [
|
8
|
+
(* TEST
|
9
|
+
"$description" >::
|
10
|
+
ae $expected ($suite-name $number);
|
11
|
+
END TEST *)
|
12
|
+
]
|
13
|
+
(* END SUITE *)
|
14
|
+
|
15
|
+
let () =
|
16
|
+
run_test_tt_main ("difference of squares tests" >::: List.concat [(* suite-all-names *)])
|
@@ -15,7 +15,7 @@ let stringify = function
|
|
15
15
|
|
16
16
|
let special_cases_tests = [
|
17
17
|
"for a non special cased slug convert the parameter to a string" >:: (fun _ctx ->
|
18
|
-
assert_equal ~printer:Fn.id "stringified" @@
|
18
|
+
assert_equal ~printer:Fn.id "stringified" @@ edit_expected ~stringify ~slug:"some-slug" ~value:(Bool true)
|
19
19
|
);
|
20
20
|
|
21
21
|
"an optional int parameter is converted to none if it matches the special value" >:: (fun _ctx ->
|
@@ -4,23 +4,57 @@ open Codegen
|
|
4
4
|
open Template
|
5
5
|
|
6
6
|
let printer = Option.value_map ~f:show ~default:"None"
|
7
|
+
let int_option_printer = Option.value_map ~f:Int.to_string ~default:"None"
|
7
8
|
|
8
9
|
let template_tests = [
|
9
|
-
"if there is no
|
10
|
+
"if there is no test marker in a string then find_template returns None" >:: (fun _ctx ->
|
10
11
|
assert_equal None @@ find_template ~template_text:"some code block"
|
11
12
|
);
|
12
13
|
|
13
|
-
"if there is
|
14
|
+
"if there is a test marker in a string then find_template returns where it is" >:: (fun _ctx ->
|
14
15
|
let template_text = In_channel.read_all "test/sample_template.txt" in
|
15
|
-
assert_equal ~printer (Some {start=7; finish=9;
|
16
|
+
assert_equal ~printer (Some {start=7; finish=9;
|
17
|
+
file_text=template_text; template="code";
|
18
|
+
suite_name_line= None;
|
19
|
+
suite_end = None;
|
20
|
+
suite_all_names_line = None}) @@ find_template ~template_text
|
21
|
+
);
|
22
|
+
|
23
|
+
"if there is a suite description line then find_template returns where it is" >:: (fun _ctx ->
|
24
|
+
let template_text = In_channel.read_all "test/sample-suite-template.txt" in
|
25
|
+
let template = find_template ~template_text in
|
26
|
+
match template with
|
27
|
+
| None -> assert_failure "Could not find a template at all"
|
28
|
+
| Some template -> assert_equal ~printer:int_option_printer (Some 6) template.suite_name_line
|
29
|
+
);
|
30
|
+
|
31
|
+
"if there is a suite all descriptions line then find_template returns where it is" >:: (fun _ctx ->
|
32
|
+
let template_text = In_channel.read_all "test/sample-suite-template.txt" in
|
33
|
+
let template = find_template ~template_text in
|
34
|
+
match template with
|
35
|
+
| None -> assert_failure "Could not find a template at all"
|
36
|
+
| Some template -> assert_equal ~printer:int_option_printer (Some 15) template.suite_all_names_line
|
16
37
|
);
|
17
38
|
|
18
39
|
"fills in lines of a template" >:: (fun _ctx ->
|
19
40
|
let template_text = In_channel.read_all "test/sample_template.txt" in
|
20
|
-
let template = {start=7; finish=9; file_text=template_text;template="code"
|
21
|
-
|
22
|
-
let
|
41
|
+
let template = {start=7; finish=9; file_text=template_text;template="code";
|
42
|
+
suite_name_line= None; suite_end = None; suite_all_names_line = None} in
|
43
|
+
let filled = fill_tests template [Subst "line1"; Subst "line2"] in
|
44
|
+
let pattern = " (* TEST\ncode\n END TEST *)" in
|
23
45
|
let expected = (String.substr_replace_all ~pattern ~with_:"line1\nline2" template_text) in
|
24
46
|
assert_equal ~printer:Fn.id expected (filled ^ "\n")
|
25
47
|
);
|
48
|
+
|
49
|
+
"fills in a single suite in a suite template" >:: (fun _ctx ->
|
50
|
+
let template_text = In_channel.read_all "test/sample-suite-template.txt" in
|
51
|
+
let template = {start=7; finish=9; file_text=template_text;template="code";
|
52
|
+
suite_name_line=Some 6; suite_end = Some 14; suite_all_names_line = None} in
|
53
|
+
let subst = ("tests1", [Subst "line1"; Subst "line2"]) in
|
54
|
+
let filled = fill_single_suite template subst in
|
55
|
+
assert_equal ~printer:Bool.to_string true (String.substr_index filled ~pattern:"let tests1_tests = [" |> Option.is_some);
|
56
|
+
assert_equal ~printer:Bool.to_string true (String.substr_index filled ~pattern:"line1" |> Option.is_some);
|
57
|
+
assert_equal ~printer:Bool.to_string true (String.substr_index filled ~pattern:"line2" |> Option.is_some);
|
58
|
+
assert_equal ~printer:Int.to_string 6 (String.count ~f:(fun ch -> ch = '\n') filled);
|
59
|
+
);
|
26
60
|
]
|
data/tracks/perl6/.travis.yml
CHANGED
@@ -1,3 +1,3 @@
|
|
1
1
|
# Resources
|
2
2
|
|
3
|
-
|
3
|
+
[The Perl6 site](https://perl6.org/) has a [resources](https://perl6.org/resources/) page containing variety of information on the language, such as guides for newcomers, documentation, and screencasts.
|
@@ -3,14 +3,10 @@ use v6;
|
|
3
3
|
use Test;
|
4
4
|
use lib IO::Path.new($?FILE).parent.path;
|
5
5
|
|
6
|
-
plan 8;
|
7
|
-
|
8
6
|
BEGIN {
|
9
|
-
|
10
|
-
|
11
|
-
}
|
12
|
-
|
13
|
-
pass 'Load module';
|
7
|
+
plan 8;
|
8
|
+
eval-lives-ok %*ENV<EXERCISM>.so ?? 'use Example' !! 'use Accumulate', 'Module loaded';
|
9
|
+
}
|
14
10
|
|
15
11
|
ok Accumulate.can('accumulate'), 'Accumulate class has accumulate() method';
|
16
12
|
|
@@ -3,14 +3,10 @@ use v6;
|
|
3
3
|
use Test;
|
4
4
|
use lib IO::Path.new($?FILE).parent.path;
|
5
5
|
|
6
|
-
plan 11;
|
7
|
-
|
8
6
|
BEGIN {
|
9
|
-
|
10
|
-
|
11
|
-
}
|
12
|
-
|
13
|
-
pass 'Load module';
|
7
|
+
plan 11;
|
8
|
+
eval-lives-ok %*ENV<EXERCISM>.so ?? 'use Example' !! 'use Anagram', 'Module loaded';
|
9
|
+
}
|
14
10
|
|
15
11
|
ok Anagram.can('match'), 'Class Anagram has match method';
|
16
12
|
|
@@ -3,14 +3,10 @@ use v6;
|
|
3
3
|
use Test;
|
4
4
|
use lib IO::Path.new($?FILE).parent.path;
|
5
5
|
|
6
|
-
plan 10;
|
7
|
-
|
8
6
|
BEGIN {
|
9
|
-
|
10
|
-
|
11
|
-
}
|
12
|
-
|
13
|
-
pass 'Load module';
|
7
|
+
plan 10;
|
8
|
+
eval-lives-ok %*ENV<EXERCISM>.so ?? 'use Example' !! 'use Binary', 'Module loaded';
|
9
|
+
}
|
14
10
|
|
15
11
|
ok Binary.can('to_decimal'), 'Class Binary has to_decimal method';
|
16
12
|
|
@@ -3,14 +3,10 @@ use v6;
|
|
3
3
|
use Test;
|
4
4
|
use lib IO::Path.new($?FILE).parent.path;
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
EVAL("use $module");
|
11
|
-
};
|
12
|
-
|
13
|
-
pass 'Load module';
|
6
|
+
BEGIN {
|
7
|
+
plan 21;
|
8
|
+
eval-lives-ok %*ENV<EXERCISM>.so ?? 'use Example' !! 'use Bob', 'Module loaded';
|
9
|
+
}
|
14
10
|
|
15
11
|
ok Bob.can('hey'), 'Class Bob has hey() method';
|
16
12
|
|
@@ -3,14 +3,10 @@ use v6;
|
|
3
3
|
use Test;
|
4
4
|
use lib IO::Path.new($?FILE).parent.path;
|
5
5
|
|
6
|
-
plan 11;
|
7
|
-
|
8
6
|
BEGIN {
|
9
|
-
|
10
|
-
|
11
|
-
}
|
12
|
-
|
13
|
-
pass 'Load module';
|
7
|
+
plan 11;
|
8
|
+
eval-lives-ok %*ENV<EXERCISM>.so ?? 'use Example' !! 'use Grains', 'Module loaded';
|
9
|
+
}
|
14
10
|
|
15
11
|
ok Grains.can('square'), 'Grains class has square method';
|
16
12
|
ok Grains.can('total'), 'Grains class has total method';
|
@@ -3,14 +3,10 @@ use v6;
|
|
3
3
|
use Test;
|
4
4
|
use lib IO::Path.new($?FILE).parent.path;
|
5
5
|
|
6
|
-
plan 8;
|
7
|
-
|
8
6
|
BEGIN {
|
9
|
-
|
10
|
-
|
11
|
-
}
|
12
|
-
|
13
|
-
pass 'Load module';
|
7
|
+
plan 8;
|
8
|
+
eval-lives-ok %*ENV<EXERCISM>.so ?? 'use Example' !! 'use Leap', 'Module loaded';
|
9
|
+
}
|
14
10
|
|
15
11
|
ok Leap.can('is_leap'), 'Leap class has is_leap() method';
|
16
12
|
|
@@ -3,14 +3,10 @@ use v6;
|
|
3
3
|
use Test;
|
4
4
|
use lib IO::Path.new($?FILE).parent.path;
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
EVAL("use $module");
|
11
|
-
};
|
12
|
-
|
13
|
-
pass 'Load module';
|
6
|
+
BEGIN {
|
7
|
+
plan 7;
|
8
|
+
eval-lives-ok %*ENV<EXERCISM>.so ?? 'use Example' !! 'use RNA_Transcription', 'Module loaded';
|
9
|
+
}
|
14
10
|
|
15
11
|
ok RNA_Transcription.can('to_rna'), 'Class RNA_Transcription has to_rna() method';
|
16
12
|
|
@@ -3,14 +3,10 @@ use v6;
|
|
3
3
|
use Test;
|
4
4
|
use lib IO::Path.new($?FILE).parent.path;
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
EVAL("use $module");
|
11
|
-
};
|
12
|
-
|
13
|
-
pass 'Load module';
|
6
|
+
BEGIN {
|
7
|
+
plan 7;
|
8
|
+
eval-lives-ok %*ENV<EXERCISM>.so ?? 'use Example' !! 'use Robot', 'Module loaded';
|
9
|
+
}
|
14
10
|
|
15
11
|
ok Robot.can('name'), 'Robot class has name attribute';
|
16
12
|
ok Robot.can('reset_name'), 'Robot class has reset_name method';
|
@@ -3,14 +3,10 @@ use v6;
|
|
3
3
|
use Test;
|
4
4
|
use lib IO::Path.new($?FILE).parent.path;
|
5
5
|
|
6
|
-
plan 10;
|
7
|
-
|
8
6
|
BEGIN {
|
9
|
-
|
10
|
-
|
11
|
-
}
|
12
|
-
|
13
|
-
pass 'Load module';
|
7
|
+
plan 10;
|
8
|
+
eval-lives-ok %*ENV<EXERCISM>.so ?? 'use Example' !! 'use Scrabble', 'Module loaded';
|
9
|
+
}
|
14
10
|
|
15
11
|
ok Scrabble.can('score'), 'Scrabble class has score() method';
|
16
12
|
|
@@ -3,15 +3,10 @@ use v6;
|
|
3
3
|
use Test;
|
4
4
|
use lib IO::Path.new($?FILE).parent.path;
|
5
5
|
|
6
|
-
plan 8;
|
7
|
-
|
8
6
|
BEGIN {
|
9
|
-
|
10
|
-
|
11
|
-
}
|
12
|
-
|
13
|
-
pass 'Load module';
|
14
|
-
|
7
|
+
plan 8;
|
8
|
+
eval-lives-ok %*ENV<EXERCISM>.so ?? 'use Example' !! 'use Word_Counter', 'Module loaded';
|
9
|
+
}
|
15
10
|
|
16
11
|
ok Word_Counter.can('count_words'), 'Class Word_Counter has count_words method';
|
17
12
|
|
data/tracks/r/config.json
CHANGED
@@ -0,0 +1,14 @@
|
|
1
|
+
R is a free, open source, programming language and software environment for statistical computing and graphics developed at Bell Laboratories as a GNU project. It is designed as a true computer language, and is written in C, Fortran and R.
|
2
|
+
|
3
|
+
R provides a wide variety of statistical (linear and nonlinear modelling, classical statistical tests, time-series analysis, classification, clustering, etc) and graphical techniques, and is highly extensible.
|
4
|
+
|
5
|
+
One of its strengths is the ease with which well-designed publication-quality plots can be produced, including mathematical symbols and formulae where needed. Great care has been taken over the defaults for the minor design choices in graphics, but the user retains full control. Along with this, for computationally-intensive tasks, C, C++ and Fortran can be linked and called at runtime or one can even write C code to manipulate R objects directly.
|
6
|
+
|
7
|
+
The R software suite includes:
|
8
|
+
* An effective data handling and storage facility,
|
9
|
+
* A suite of operators for calculations on arrays, in particular matrices,
|
10
|
+
* A large, coherent, integrated collection of intermediate tools for data analysis,
|
11
|
+
* graphical facilities for data analysis and display either on-screen or on hardcopy, and
|
12
|
+
* A well-developed, simple and effective programming language which includes conditionals, loops, user-defined recursive functions and input and output facilities.
|
13
|
+
* The term “environment” is intended to characterize it as a fully planned and coherent system, rather than an incremental accretion of very specific and inflexible tools, as is frequently the case with other data analysis software.
|
14
|
+
* R can be extended (easily) via packages. There are about eight packages supplied with the R distribution and many more are available through the CRAN family of Internet sites covering a very wide range of modern statistics.
|
@@ -0,0 +1,23 @@
|
|
1
|
+
source('./difference-of-squares.R')
|
2
|
+
suppressPackageStartupMessages({ require(testthat) })
|
3
|
+
|
4
|
+
test_that("difference of squares 0", {
|
5
|
+
input <- 0
|
6
|
+
expect_equal(difference_of_squares(input), 0)
|
7
|
+
})
|
8
|
+
|
9
|
+
test_that("difference of squares 5", {
|
10
|
+
input <- 5
|
11
|
+
expect_equal(difference_of_squares(input), 170)
|
12
|
+
})
|
13
|
+
|
14
|
+
test_that("difference of squares 10", {
|
15
|
+
input <- 10
|
16
|
+
expect_equal(difference_of_squares(input), 2640)
|
17
|
+
})
|
18
|
+
|
19
|
+
test_that("difference of squares 100", {
|
20
|
+
input <- 100
|
21
|
+
expect_equal(difference_of_squares(input), 25164150)
|
22
|
+
})
|
23
|
+
|
@@ -0,0 +1,87 @@
|
|
1
|
+
source('./hamming.R')
|
2
|
+
suppressPackageStartupMessages({ require(testthat) })
|
3
|
+
|
4
|
+
test_that("identical strands", {
|
5
|
+
strand1 <-"A"
|
6
|
+
strand2 <- "A"
|
7
|
+
expect_equal(hamming(strand1, strand2), 0)
|
8
|
+
})
|
9
|
+
|
10
|
+
test_that("long identical strands", {
|
11
|
+
strand1 <-"GGACTGA"
|
12
|
+
strand2 <- "GGACTGA"
|
13
|
+
expect_equal(hamming(strand1, strand2), 0)
|
14
|
+
})
|
15
|
+
|
16
|
+
test_that("complete distance in single nucleotide strands", {
|
17
|
+
strand1 <-"A"
|
18
|
+
strand2 <- "G"
|
19
|
+
expect_equal(hamming(strand1, strand2), 1)
|
20
|
+
})
|
21
|
+
|
22
|
+
test_that("complete distance in small strands", {
|
23
|
+
strand1 <-"AG"
|
24
|
+
strand2 <- "CT"
|
25
|
+
expect_equal(hamming(strand1, strand2), 2)
|
26
|
+
})
|
27
|
+
|
28
|
+
test_that("small distance in small strands", {
|
29
|
+
strand1 <-"AT"
|
30
|
+
strand2 <- "CT"
|
31
|
+
expect_equal(hamming(strand1, strand2), 1)
|
32
|
+
})
|
33
|
+
|
34
|
+
test_that("small distance", {
|
35
|
+
strand1 <-"GGACG"
|
36
|
+
strand2 <- "GGTCG"
|
37
|
+
expect_equal(hamming(strand1, strand2), 1)
|
38
|
+
})
|
39
|
+
|
40
|
+
test_that("small distance in long strands", {
|
41
|
+
strand1 <-"ACCAGGG"
|
42
|
+
strand2 <- "ACTATGG"
|
43
|
+
expect_equal(hamming(strand1, strand2), 2)
|
44
|
+
})
|
45
|
+
|
46
|
+
test_that("non-unique character in first strand", {
|
47
|
+
strand1 <-"AGA"
|
48
|
+
strand2 <- "AGG"
|
49
|
+
expect_equal(hamming(strand1, strand2), 1)
|
50
|
+
})
|
51
|
+
|
52
|
+
test_that("non-unique character in second strand", {
|
53
|
+
strand1 <-"AGG"
|
54
|
+
strand2 <- "AGA"
|
55
|
+
expect_equal(hamming(strand1, strand2), 1)
|
56
|
+
})
|
57
|
+
|
58
|
+
test_that("same nucleotides in different positions", {
|
59
|
+
strand1 <-"TAG"
|
60
|
+
strand2 <- "GAT"
|
61
|
+
expect_equal(hamming(strand1, strand2), 2)
|
62
|
+
})
|
63
|
+
|
64
|
+
test_that("large distance", {
|
65
|
+
strand1 <-"GATACA"
|
66
|
+
strand2 <- "GCATAA"
|
67
|
+
expect_equal(hamming(strand1, strand2), 4)
|
68
|
+
})
|
69
|
+
|
70
|
+
test_that("empty strands", {
|
71
|
+
strand1 <-""
|
72
|
+
strand2 <- ""
|
73
|
+
expect_equal(hamming(strand1, strand2), 0)
|
74
|
+
})
|
75
|
+
|
76
|
+
test_that("disallow first strand longer", {
|
77
|
+
strand1 <-"AATG"
|
78
|
+
strand2 <- "AAA"
|
79
|
+
expect_error(hamming(strand1, strand2))
|
80
|
+
})
|
81
|
+
|
82
|
+
test_that("disallow second strand longer", {
|
83
|
+
strand1 <-"ATA"
|
84
|
+
strand2 <- "AGTG"
|
85
|
+
expect_error(hamming(strand1, strand2))
|
86
|
+
})
|
87
|
+
|