trackler 2.2.1.162 → 2.2.1.163
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/bash/config.json +2 -1
- data/tracks/c/docs/ABOUT.md +3 -3
- data/tracks/c/docs/SNIPPET.txt +3 -4
- data/tracks/common-lisp/docs/RESOURCES.md +1 -1
- data/tracks/cpp/config.json +1 -0
- data/tracks/csharp/exercises/pov/Example.cs +49 -53
- data/tracks/csharp/exercises/pov/Pov.cs +5 -25
- data/tracks/csharp/exercises/pov/PovTest.cs +127 -110
- data/tracks/csharp/exercises/react/Example.cs +3 -5
- data/tracks/csharp/exercises/react/React.csproj +1 -0
- data/tracks/csharp/exercises/react/ReactTest.cs +167 -78
- data/tracks/csharp/exercises/simple-cipher/Example.cs +18 -21
- data/tracks/csharp/exercises/simple-cipher/SimpleCipher.cs +3 -3
- data/tracks/csharp/exercises/simple-cipher/SimpleCipherTest.cs +43 -79
- data/tracks/csharp/generators/Exercises/Pov.cs +54 -0
- data/tracks/csharp/generators/Exercises/React.cs +136 -0
- data/tracks/csharp/generators/Exercises/SimpleCipher.cs +67 -0
- data/tracks/elixir/config/maintainers.json +16 -16
- data/tracks/elixir/config.json +370 -369
- data/tracks/java/config.json +1 -1
- data/tracks/racket/docs/LEARNING.md +1 -1
- data/tracks/sml/config/maintainers.json +8 -8
- data/tracks/sml/config.json +57 -103
- data/tracks/sml/exercises/nth-prime/.meta/hints.md +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 76612316f315c3fe85ebb27ebc85f29488a65b74
|
4
|
+
data.tar.gz: c97049c73a649f2216b10ba50f56003b6b64deda
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1f4fc4a223296db0466472ad905734207eff98965acfbc43db71ee8e6572bd566ebea8d70c799a70aad6bedbe6e66693229fd0dfb57886084096a50b28ef2a35
|
7
|
+
data.tar.gz: 8f862eda68d3bb98bb2bd362b76f650a6f6d4597134b6d2aed7110e60b6015147f2afeee7a00677c4b71a3c762494bfab67106463becf051552f2395b36801c5
|
data/lib/trackler/version.rb
CHANGED
data/tracks/bash/config.json
CHANGED
data/tracks/c/docs/ABOUT.md
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
C is a general
|
1
|
+
C is a general purpose language, used for a wide range of applications, from embedded computers to high-performance computing clusters.
|
2
2
|
|
3
|
-
C
|
3
|
+
C is commonly found in low level applications as it's a good alternative to harder-to-read assembly languages. It can be compiled to assembly to keep the same level of performance, while increasing readability, and providing a small level of safety with static types!
|
4
4
|
|
5
|
-
|
5
|
+
C was created by Dennis Ritchie at Bell Labs, and used to re-implement the Unix operating system. Now, it's one of the most used programming languages, with many compilers supporting providing support for most available hardware and platforms - there's plenty of resources and support available to help you get started!
|
data/tracks/c/docs/SNIPPET.txt
CHANGED
@@ -24,7 +24,7 @@ most popularly linked introductory works.
|
|
24
24
|
by David S. Touretzky
|
25
25
|
* [Common Lisp: An Interactive Approach](http://www.cse.buffalo.edu/~shapiro/Commonlisp/) (PDF),
|
26
26
|
by Stuart C. Shapiro
|
27
|
-
* [Successful Lisp: How to Understand and Use Common Lisp](http://
|
27
|
+
* [Successful Lisp: How to Understand and Use Common Lisp](http://successful-lisp.blogspot.com/),
|
28
28
|
by David B. Lamkins
|
29
29
|
|
30
30
|
Following these are two more advanced books, but beginners shouldn't
|
data/tracks/cpp/config.json
CHANGED
@@ -2,75 +2,72 @@
|
|
2
2
|
using System.Collections.Generic;
|
3
3
|
using System.Linq;
|
4
4
|
|
5
|
-
public class
|
5
|
+
public class Tree : IEquatable<Tree>
|
6
6
|
{
|
7
|
-
public
|
8
|
-
|
9
|
-
Value = value;
|
10
|
-
Children = children;
|
11
|
-
}
|
7
|
+
public Tree(string value, params Tree[] children)
|
8
|
+
=> (Value, Children) = (value, children);
|
12
9
|
|
13
|
-
public
|
14
|
-
public
|
10
|
+
public string Value { get; }
|
11
|
+
public Tree[] Children { get; }
|
15
12
|
|
16
|
-
public bool Equals(
|
17
|
-
Value.Equals(other.Value) &&
|
13
|
+
public bool Equals(Tree other)
|
14
|
+
=> Value.Equals(other.Value) &&
|
15
|
+
Children.OrderBy(child => child.Value).SequenceEqual(other.Children.OrderBy(child => child.Value));
|
18
16
|
}
|
19
17
|
|
20
|
-
public class
|
18
|
+
public class TreeCrumb
|
21
19
|
{
|
22
|
-
public
|
23
|
-
|
24
|
-
Value = value;
|
25
|
-
Left = left;
|
26
|
-
Right = right;
|
27
|
-
}
|
20
|
+
public TreeCrumb(string value, IEnumerable<Tree> left, IEnumerable<Tree> right)
|
21
|
+
=> (Value, Left, Right) = (value, left, right);
|
28
22
|
|
29
|
-
public
|
30
|
-
public IEnumerable<
|
31
|
-
public IEnumerable<
|
23
|
+
public string Value { get; }
|
24
|
+
public IEnumerable<Tree> Left { get; }
|
25
|
+
public IEnumerable<Tree> Right { get; }
|
32
26
|
}
|
33
27
|
|
34
|
-
public class
|
28
|
+
public class TreeZipper
|
35
29
|
{
|
36
|
-
public
|
37
|
-
|
38
|
-
Focus = focus;
|
39
|
-
Crumbs = crumbs;
|
40
|
-
}
|
30
|
+
public TreeZipper(Tree focus, IEnumerable<TreeCrumb> crumbs)
|
31
|
+
=> (Focus, Crumbs) = (focus, crumbs);
|
41
32
|
|
42
|
-
public
|
43
|
-
public IEnumerable<
|
33
|
+
public Tree Focus { get; }
|
34
|
+
public IEnumerable<TreeCrumb> Crumbs { get; }
|
44
35
|
}
|
45
36
|
|
46
37
|
public static class Pov
|
47
38
|
{
|
48
|
-
public static
|
49
|
-
|
39
|
+
public static Tree FromPov(Tree graph, string value)
|
40
|
+
{
|
41
|
+
var zipper = FindNode(value, GraphToZipper(graph));
|
42
|
+
if (zipper == null)
|
43
|
+
throw new ArgumentException();
|
44
|
+
|
45
|
+
return ChangeParent(zipper);
|
46
|
+
}
|
50
47
|
|
51
|
-
public static
|
52
|
-
|
48
|
+
public static IEnumerable<string> PathTo(string value1, string value2, Tree graph)
|
49
|
+
{
|
50
|
+
var zipper = FindNode(value2, GraphToZipper(FromPov(graph, value1)));
|
51
|
+
if (zipper == null)
|
52
|
+
throw new ArgumentException();
|
53
53
|
|
54
|
-
|
55
|
-
|
54
|
+
return ZipperToPath(zipper);
|
55
|
+
}
|
56
56
|
|
57
|
-
private static
|
57
|
+
private static TreeZipper GraphToZipper(Tree graph)
|
58
58
|
{
|
59
59
|
if (graph == null)
|
60
60
|
return null;
|
61
61
|
|
62
|
-
return new
|
62
|
+
return new TreeZipper(graph, Enumerable.Empty<TreeCrumb>());
|
63
63
|
}
|
64
64
|
|
65
|
-
private static IEnumerable<
|
65
|
+
private static IEnumerable<string> ZipperToPath(TreeZipper zipper)
|
66
66
|
{
|
67
|
-
|
68
|
-
return null;
|
69
|
-
|
70
|
-
return zipper.Crumbs.Select(c => c.Value).Reverse().Concat(new[] { zipper.Focus.Value });
|
67
|
+
return zipper?.Crumbs.Select(c => c.Value).Reverse().Concat(new[] { zipper.Focus.Value });
|
71
68
|
}
|
72
69
|
|
73
|
-
private static
|
70
|
+
private static TreeZipper GoDown(TreeZipper zipper)
|
74
71
|
{
|
75
72
|
if (zipper == null || !zipper.Focus.Children.Any())
|
76
73
|
return null;
|
@@ -78,12 +75,12 @@ public static class Pov
|
|
78
75
|
var focus = zipper.Focus;
|
79
76
|
var children = focus.Children;
|
80
77
|
|
81
|
-
var newCrumb = new
|
78
|
+
var newCrumb = new TreeCrumb(focus.Value, Array.Empty<Tree>(), children.Skip(1).ToArray());
|
82
79
|
|
83
|
-
return new
|
80
|
+
return new TreeZipper(children.First(), new[] { newCrumb }.Concat(zipper.Crumbs));
|
84
81
|
}
|
85
82
|
|
86
|
-
private static
|
83
|
+
private static TreeZipper GoRight(TreeZipper zipper)
|
87
84
|
{
|
88
85
|
if (zipper == null || !zipper.Crumbs.Any() || !zipper.Crumbs.First().Right.Any())
|
89
86
|
return null;
|
@@ -91,13 +88,12 @@ public static class Pov
|
|
91
88
|
var crumbs = zipper.Crumbs;
|
92
89
|
var firstCrumb = crumbs.First();
|
93
90
|
|
94
|
-
var newCrumb = new
|
91
|
+
var newCrumb = new TreeCrumb(firstCrumb.Value, firstCrumb.Left.Concat(new[] { zipper.Focus }).ToArray(), firstCrumb.Right.Skip(1).ToArray());
|
95
92
|
|
96
|
-
return new
|
93
|
+
return new TreeZipper(firstCrumb.Right.First(), new[] { newCrumb }.Concat(crumbs.Skip(1)));
|
97
94
|
}
|
98
95
|
|
99
|
-
private static
|
100
|
-
where T : IComparable
|
96
|
+
private static TreeZipper FindNode(string value, TreeZipper zipper)
|
101
97
|
{
|
102
98
|
if (zipper == null || zipper.Focus.Value.CompareTo(value) == 0)
|
103
99
|
return zipper;
|
@@ -105,7 +101,7 @@ public static class Pov
|
|
105
101
|
return FindNode(value, GoDown(zipper)) ?? FindNode(value, GoRight(zipper));
|
106
102
|
}
|
107
103
|
|
108
|
-
private static
|
104
|
+
private static Tree ChangeParent(TreeZipper zipper)
|
109
105
|
{
|
110
106
|
if (zipper == null)
|
111
107
|
return null;
|
@@ -116,10 +112,10 @@ public static class Pov
|
|
116
112
|
var firstCrumb = zipper.Crumbs.First();
|
117
113
|
var focus = zipper.Focus;
|
118
114
|
|
119
|
-
var newZipper = new
|
115
|
+
var newZipper = new TreeZipper(new Tree(firstCrumb.Value, firstCrumb.Left.Concat(firstCrumb.Right).ToArray()), zipper.Crumbs.Skip(1));
|
120
116
|
var parentGraph = ChangeParent(newZipper);
|
121
117
|
|
122
|
-
var ys = focus.Children.Concat(new[] { parentGraph });
|
123
|
-
return
|
118
|
+
var ys = focus.Children.Concat(new[] { parentGraph }).ToArray();
|
119
|
+
return new Tree(focus.Value, ys);
|
124
120
|
}
|
125
121
|
}
|
@@ -1,42 +1,22 @@
|
|
1
1
|
using System;
|
2
2
|
using System.Collections.Generic;
|
3
3
|
|
4
|
-
public class
|
4
|
+
public class Tree
|
5
5
|
{
|
6
|
-
public
|
6
|
+
public Tree(string value, params Tree[] children)
|
7
7
|
{
|
8
|
-
|
9
|
-
|
10
|
-
public T Value
|
11
|
-
{
|
12
|
-
get
|
13
|
-
{
|
14
|
-
throw new NotImplementedException("You need to implement this function.");
|
15
|
-
}
|
16
|
-
}
|
17
|
-
|
18
|
-
public IEnumerable<Graph<T>> Children
|
19
|
-
{
|
20
|
-
get
|
21
|
-
{
|
22
|
-
throw new NotImplementedException("You need to implement this function.");
|
23
|
-
}
|
8
|
+
throw new NotImplementedException("You need to implement this function.");
|
24
9
|
}
|
25
10
|
}
|
26
11
|
|
27
12
|
public static class Pov
|
28
13
|
{
|
29
|
-
public static
|
30
|
-
{
|
31
|
-
throw new NotImplementedException("You need to implement this function.");
|
32
|
-
}
|
33
|
-
|
34
|
-
public static Graph<T> FromPOV<T>(T value, Graph<T> graph) where T : IComparable
|
14
|
+
public static Tree FromPov(Tree tree, string from)
|
35
15
|
{
|
36
16
|
throw new NotImplementedException("You need to implement this function.");
|
37
17
|
}
|
38
18
|
|
39
|
-
public static IEnumerable<
|
19
|
+
public static IEnumerable<string> PathTo(string from, string to, Tree tree)
|
40
20
|
{
|
41
21
|
throw new NotImplementedException("You need to implement this function.");
|
42
22
|
}
|
@@ -1,154 +1,171 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
// This file was auto-generated based on version 1.3.0 of the canonical data.
|
2
|
+
|
3
|
+
using Xunit;
|
4
|
+
using System;
|
3
5
|
|
4
6
|
public class PovTest
|
5
7
|
{
|
6
|
-
private const string x = "x";
|
7
|
-
|
8
|
-
private static Graph<T> leaf<T>(T v) => Pov.CreateGraph(v, new Graph<T>[0]);
|
9
|
-
|
10
|
-
private static readonly Graph<string> singleton = Pov.CreateGraph(x, new Graph<string>[0]);
|
11
|
-
|
12
|
-
private static readonly Graph<string> flat = Pov.CreateGraph("root", new[] { "a", "b", x, "c" }.Select(leaf));
|
13
|
-
|
14
|
-
private static readonly Graph<string> nested =
|
15
|
-
Pov.CreateGraph("level-0", new[] {
|
16
|
-
Pov.CreateGraph("level-1", new[] {
|
17
|
-
Pov.CreateGraph("level-2", new[] {
|
18
|
-
Pov.CreateGraph("level-3", new[] {
|
19
|
-
Pov.CreateGraph(x, new Graph<string>[0])
|
20
|
-
})
|
21
|
-
})
|
22
|
-
})
|
23
|
-
});
|
24
|
-
|
25
|
-
private static readonly Graph<string> kids =
|
26
|
-
Pov.CreateGraph("root", new[] {
|
27
|
-
Pov.CreateGraph(x, new[] {
|
28
|
-
Pov.CreateGraph("kid-0", new Graph<string>[0]),
|
29
|
-
Pov.CreateGraph("kid-1", new Graph<string>[0])
|
30
|
-
})
|
31
|
-
});
|
32
|
-
|
33
|
-
private static readonly Graph<string> cousins =
|
34
|
-
Pov.CreateGraph("grandparent", new[] {
|
35
|
-
Pov.CreateGraph("parent", new [] {
|
36
|
-
Pov.CreateGraph(x, new [] {
|
37
|
-
leaf("kid-a"),
|
38
|
-
leaf("kid-b")
|
39
|
-
}),
|
40
|
-
leaf("sibling-0"),
|
41
|
-
leaf("sibling-1")
|
42
|
-
}),
|
43
|
-
Pov.CreateGraph("uncle", new [] {
|
44
|
-
leaf("cousin-0"),
|
45
|
-
leaf("cousin-1")
|
46
|
-
})
|
47
|
-
});
|
48
|
-
|
49
|
-
private static readonly Graph<string> singleton_ = singleton;
|
50
|
-
|
51
|
-
private static readonly Graph<string> flat_ =
|
52
|
-
Pov.CreateGraph(x, new[] {
|
53
|
-
Pov.CreateGraph("root", new [] { "a", "b", "c" }.Select(leaf))
|
54
|
-
});
|
55
|
-
|
56
|
-
private static readonly Graph<string> nested_ =
|
57
|
-
Pov.CreateGraph(x, new[] {
|
58
|
-
Pov.CreateGraph("level-3", new [] {
|
59
|
-
Pov.CreateGraph("level-2", new [] {
|
60
|
-
Pov.CreateGraph("level-1", new [] {
|
61
|
-
Pov.CreateGraph("level-0", new Graph<string>[0])
|
62
|
-
})
|
63
|
-
})
|
64
|
-
})
|
65
|
-
});
|
66
|
-
|
67
|
-
private static readonly Graph<string> kids_ =
|
68
|
-
Pov.CreateGraph(x, new[] {
|
69
|
-
Pov.CreateGraph("kid-0", new Graph<string>[0]),
|
70
|
-
Pov.CreateGraph("kid-1", new Graph<string>[0]),
|
71
|
-
Pov.CreateGraph("root", new Graph<string>[0])
|
72
|
-
});
|
73
|
-
|
74
|
-
private static readonly Graph<string> cousins_ =
|
75
|
-
Pov.CreateGraph(x, new[] {
|
76
|
-
leaf("kid-a"),
|
77
|
-
leaf("kid-b"),
|
78
|
-
Pov.CreateGraph("parent", new [] {
|
79
|
-
Pov.CreateGraph("sibling-0", new Graph<string>[0]),
|
80
|
-
Pov.CreateGraph("sibling-1", new Graph<string>[0]),
|
81
|
-
Pov.CreateGraph("grandparent", new [] {
|
82
|
-
Pov.CreateGraph("uncle", new [] {
|
83
|
-
Pov.CreateGraph("cousin-0", new Graph<string>[0]),
|
84
|
-
Pov.CreateGraph("cousin-1", new Graph<string>[0])
|
85
|
-
})
|
86
|
-
})
|
87
|
-
})
|
88
|
-
});
|
89
|
-
|
90
8
|
[Fact]
|
91
|
-
public void
|
9
|
+
public void Results_in_the_same_tree_if_the_input_tree_is_a_singleton()
|
10
|
+
{
|
11
|
+
var tree = new Tree("x");
|
12
|
+
var from = "x";
|
13
|
+
var expected = new Tree("x");
|
14
|
+
Assert.Equal(expected, Pov.FromPov(tree, from));
|
15
|
+
}
|
16
|
+
|
17
|
+
[Fact(Skip = "Remove to run test")]
|
18
|
+
public void Can_reroot_a_tree_with_a_parent_and_one_sibling()
|
19
|
+
{
|
20
|
+
var tree = new Tree("parent", new Tree("x"), new Tree("sibling"));
|
21
|
+
var from = "x";
|
22
|
+
var expected = new Tree("x", new Tree("parent", new Tree("sibling")));
|
23
|
+
Assert.Equal(expected, Pov.FromPov(tree, from));
|
24
|
+
}
|
25
|
+
|
26
|
+
[Fact(Skip = "Remove to run test")]
|
27
|
+
public void Can_reroot_a_tree_with_a_parent_and_many_siblings()
|
28
|
+
{
|
29
|
+
var tree = new Tree("parent", new Tree("a"), new Tree("x"), new Tree("b"), new Tree("c"));
|
30
|
+
var from = "x";
|
31
|
+
var expected = new Tree("x", new Tree("parent", new Tree("a"), new Tree("b"), new Tree("c")));
|
32
|
+
Assert.Equal(expected, Pov.FromPov(tree, from));
|
33
|
+
}
|
34
|
+
|
35
|
+
[Fact(Skip = "Remove to run test")]
|
36
|
+
public void Can_reroot_a_tree_with_new_root_deeply_nested_in_tree()
|
92
37
|
{
|
93
|
-
|
38
|
+
var tree = new Tree("level-0", new Tree("level-1", new Tree("level-2", new Tree("level-3", new Tree("x")))));
|
39
|
+
var from = "x";
|
40
|
+
var expected = new Tree("x", new Tree("level-3", new Tree("level-2", new Tree("level-1", new Tree("level-0")))));
|
41
|
+
Assert.Equal(expected, Pov.FromPov(tree, from));
|
94
42
|
}
|
95
43
|
|
96
44
|
[Fact(Skip = "Remove to run test")]
|
97
|
-
public void
|
45
|
+
public void Moves_children_of_the_new_root_to_same_level_as_former_parent()
|
98
46
|
{
|
99
|
-
|
47
|
+
var tree = new Tree("parent", new Tree("x", new Tree("kid-0"), new Tree("kid-1")));
|
48
|
+
var from = "x";
|
49
|
+
var expected = new Tree("x", new Tree("kid-0"), new Tree("kid-1"), new Tree("parent"));
|
50
|
+
Assert.Equal(expected, Pov.FromPov(tree, from));
|
100
51
|
}
|
101
52
|
|
102
53
|
[Fact(Skip = "Remove to run test")]
|
103
|
-
public void
|
54
|
+
public void Can_reroot_a_complex_tree_with_cousins()
|
104
55
|
{
|
105
|
-
|
56
|
+
var tree = new Tree("grandparent", new Tree("parent", new Tree("x", new Tree("kid-0"), new Tree("kid-1")), new Tree("sibling-0"), new Tree("sibling-1")), new Tree("uncle", new Tree("cousin-0"), new Tree("cousin-1")));
|
57
|
+
var from = "x";
|
58
|
+
var expected = new Tree("x", new Tree("kid-1"), new Tree("kid-0"), new Tree("parent", new Tree("sibling-0"), new Tree("sibling-1"), new Tree("grandparent", new Tree("uncle", new Tree("cousin-0"), new Tree("cousin-1")))));
|
59
|
+
Assert.Equal(expected, Pov.FromPov(tree, from));
|
106
60
|
}
|
107
61
|
|
108
62
|
[Fact(Skip = "Remove to run test")]
|
109
|
-
public void
|
63
|
+
public void Errors_if_target_does_not_exist_in_a_singleton_tree()
|
110
64
|
{
|
111
|
-
|
65
|
+
var tree = new Tree("x");
|
66
|
+
var from = "nonexistent";
|
67
|
+
Assert.Throws<ArgumentException>(() => Pov.FromPov(tree, from));
|
112
68
|
}
|
113
69
|
|
114
70
|
[Fact(Skip = "Remove to run test")]
|
115
|
-
public void
|
71
|
+
public void Errors_if_target_does_not_exist_in_a_large_tree()
|
116
72
|
{
|
117
|
-
|
73
|
+
var tree = new Tree("parent", new Tree("x", new Tree("kid-0"), new Tree("kid-1")), new Tree("sibling-0"), new Tree("sibling-1"));
|
74
|
+
var from = "nonexistent";
|
75
|
+
Assert.Throws<ArgumentException>(() => Pov.FromPov(tree, from));
|
118
76
|
}
|
119
77
|
|
120
78
|
[Fact(Skip = "Remove to run test")]
|
121
|
-
public void
|
79
|
+
public void Can_find_path_to_parent()
|
122
80
|
{
|
123
|
-
|
81
|
+
var from = "x";
|
82
|
+
var to = "parent";
|
83
|
+
var tree = new Tree("parent", new Tree("x"), new Tree("sibling"));
|
84
|
+
var expected = new[]
|
85
|
+
{
|
86
|
+
"x",
|
87
|
+
"parent"
|
88
|
+
};
|
89
|
+
Assert.Equal(expected, Pov.PathTo(from, to, tree));
|
90
|
+
}
|
91
|
+
|
92
|
+
[Fact(Skip = "Remove to run test")]
|
93
|
+
public void Can_find_path_to_sibling()
|
94
|
+
{
|
95
|
+
var from = "x";
|
96
|
+
var to = "b";
|
97
|
+
var tree = new Tree("parent", new Tree("a"), new Tree("x"), new Tree("b"), new Tree("c"));
|
98
|
+
var expected = new[]
|
99
|
+
{
|
100
|
+
"x",
|
101
|
+
"parent",
|
102
|
+
"b"
|
103
|
+
};
|
104
|
+
Assert.Equal(expected, Pov.PathTo(from, to, tree));
|
124
105
|
}
|
125
106
|
|
126
107
|
[Fact(Skip = "Remove to run test")]
|
127
|
-
public void
|
108
|
+
public void Can_find_path_to_cousin()
|
128
109
|
{
|
129
|
-
var
|
130
|
-
|
131
|
-
|
110
|
+
var from = "x";
|
111
|
+
var to = "cousin-1";
|
112
|
+
var tree = new Tree("grandparent", new Tree("parent", new Tree("x", new Tree("kid-0"), new Tree("kid-1")), new Tree("sibling-0"), new Tree("sibling-1")), new Tree("uncle", new Tree("cousin-0"), new Tree("cousin-1")));
|
113
|
+
var expected = new[]
|
132
114
|
{
|
133
|
-
|
134
|
-
|
115
|
+
"x",
|
116
|
+
"parent",
|
117
|
+
"grandparent",
|
118
|
+
"uncle",
|
119
|
+
"cousin-1"
|
120
|
+
};
|
121
|
+
Assert.Equal(expected, Pov.PathTo(from, to, tree));
|
135
122
|
}
|
136
123
|
|
137
124
|
[Fact(Skip = "Remove to run test")]
|
138
|
-
public void
|
125
|
+
public void Can_find_path_not_involving_root()
|
139
126
|
{
|
140
|
-
|
127
|
+
var from = "x";
|
128
|
+
var to = "sibling-1";
|
129
|
+
var tree = new Tree("grandparent", new Tree("parent", new Tree("x"), new Tree("sibling-0"), new Tree("sibling-1")));
|
130
|
+
var expected = new[]
|
131
|
+
{
|
132
|
+
"x",
|
133
|
+
"parent",
|
134
|
+
"sibling-1"
|
135
|
+
};
|
136
|
+
Assert.Equal(expected, Pov.PathTo(from, to, tree));
|
137
|
+
}
|
138
|
+
|
139
|
+
[Fact(Skip = "Remove to run test")]
|
140
|
+
public void Can_find_path_from_nodes_other_than_x()
|
141
|
+
{
|
142
|
+
var from = "a";
|
143
|
+
var to = "c";
|
144
|
+
var tree = new Tree("parent", new Tree("a"), new Tree("x"), new Tree("b"), new Tree("c"));
|
145
|
+
var expected = new[]
|
146
|
+
{
|
147
|
+
"a",
|
148
|
+
"parent",
|
149
|
+
"c"
|
150
|
+
};
|
151
|
+
Assert.Equal(expected, Pov.PathTo(from, to, tree));
|
141
152
|
}
|
142
153
|
|
143
154
|
[Fact(Skip = "Remove to run test")]
|
144
|
-
public void
|
155
|
+
public void Errors_if_destination_does_not_exist()
|
145
156
|
{
|
146
|
-
|
157
|
+
var from = "x";
|
158
|
+
var to = "nonexistent";
|
159
|
+
var tree = new Tree("parent", new Tree("x", new Tree("kid-0"), new Tree("kid-1")), new Tree("sibling-0"), new Tree("sibling-1"));
|
160
|
+
Assert.Throws<ArgumentException>(() => Pov.PathTo(from, to, tree));
|
147
161
|
}
|
148
162
|
|
149
163
|
[Fact(Skip = "Remove to run test")]
|
150
|
-
public void
|
164
|
+
public void Errors_if_source_does_not_exist()
|
151
165
|
{
|
152
|
-
|
166
|
+
var from = "nonexistent";
|
167
|
+
var to = "x";
|
168
|
+
var tree = new Tree("parent", new Tree("x", new Tree("kid-0"), new Tree("kid-1")), new Tree("sibling-0"), new Tree("sibling-1"));
|
169
|
+
Assert.Throws<ArgumentException>(() => Pov.PathTo(from, to, tree));
|
153
170
|
}
|
154
171
|
}
|
@@ -3,8 +3,6 @@ using System.Collections;
|
|
3
3
|
using System.Collections.Generic;
|
4
4
|
using System.Linq;
|
5
5
|
|
6
|
-
public delegate void ChangedEventHandler(object sender, int value);
|
7
|
-
|
8
6
|
public class Reactor
|
9
7
|
{
|
10
8
|
private readonly Dictionary<int, Cell> cells = new Dictionary<int, Cell>();
|
@@ -61,7 +59,7 @@ public abstract class Cell
|
|
61
59
|
public List<Cell> Consumers { get; }
|
62
60
|
|
63
61
|
public abstract int Value { get; set; }
|
64
|
-
public abstract event
|
62
|
+
public abstract event EventHandler<int> Changed;
|
65
63
|
}
|
66
64
|
|
67
65
|
public class InputCell : Cell
|
@@ -73,7 +71,7 @@ public class InputCell : Cell
|
|
73
71
|
_value = value;
|
74
72
|
}
|
75
73
|
|
76
|
-
public override event
|
74
|
+
public override event EventHandler<int> Changed;
|
77
75
|
|
78
76
|
public override int Value
|
79
77
|
{
|
@@ -109,7 +107,7 @@ public class ComputeCell : Cell
|
|
109
107
|
}
|
110
108
|
|
111
109
|
public override int Value { get; set; }
|
112
|
-
public override event
|
110
|
+
public override event EventHandler<int> Changed;
|
113
111
|
|
114
112
|
public void Recompute()
|
115
113
|
{
|
@@ -12,6 +12,7 @@
|
|
12
12
|
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.5.0" />
|
13
13
|
<PackageReference Include="xunit" Version="2.3.1" />
|
14
14
|
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" />
|
15
|
+
<PackageReference Include="FakeItEasy" Version="4.6.0" />
|
15
16
|
</ItemGroup>
|
16
17
|
|
17
18
|
</Project>
|