trackler 2.0.6.35 → 2.0.6.36

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b60180d66cb803d7af0b313725e9f050d9dc61b0
4
- data.tar.gz: cba72b210897ddba5ce87dc79ca7541e9615ab43
3
+ metadata.gz: 8b98826af252625c0ee25312e8d6e7d0559d62ce
4
+ data.tar.gz: 1033d0f0d124ed5a5b5be7be0f905294a10fafe9
5
5
  SHA512:
6
- metadata.gz: cdaf21409803ea63c534daeca46434a8463f75b65a8e4a3908b924598786f69e90e4c7335b344ba48a60098215eac3c11ec510820e3f36081e1c9baddd23a8b7
7
- data.tar.gz: a0b9a0e0ce5411a07b0a5e3221fcebe7da097c20cb83843fb3252d4c9d72f6a44d8861c7925eaf88738fcaff3011cf7e0141c82c38d7a7b2d0b5e45b1cc96bcd
6
+ metadata.gz: 1cc546d150c52d181ebd3a13e20fcbe0ed2b01c9477d21f43fbd0686af787feead08794076a42f63cb3fb4dcffc8cc0075f83a71a577d64234c3667f7324629d
7
+ data.tar.gz: 97481fdacba33c88b1910c287ee081abe040e546aa1bf3dee676b8449f9d1e5345ad057c89eba5428ccfd04c923d8a2e9ea35e41cde95cba7b7ce82bf14f7f9b
@@ -1,3 +1,3 @@
1
1
  module Trackler
2
- VERSION = "2.0.6.35"
2
+ VERSION = "2.0.6.36"
3
3
  end
@@ -6,12 +6,59 @@ open Acronym
6
6
  [<Test>]
7
7
  let ``Empty string abbreviated to empty string`` () =
8
8
  Assert.That(acronym "", Is.EqualTo(""))
9
-
10
- [<TestCase("Portable Network Graphics", ExpectedResult = "PNG", Ignore = "Remove to run test case")>]
11
- [<TestCase("Ruby on Rails", ExpectedResult = "ROR", Ignore = "Remove to run test case")>]
12
- [<TestCase("HyperText Markup Language", ExpectedResult = "HTML", Ignore = "Remove to run test case")>]
13
- [<TestCase("First In, First Out", ExpectedResult = "FIFO", Ignore = "Remove to run test case")>]
14
- [<TestCase("PHP: Hypertext Preprocessor", ExpectedResult = "PHP", Ignore = "Remove to run test case")>]
15
- [<TestCase("Complementary metal-oxide semiconductor", ExpectedResult = "CMOS", Ignore = "Remove to run test case")>]
16
- let ``Phrase abbreviated to acronym`` (phrase: string) =
17
- acronym phrase
9
+
10
+ [<Test>]
11
+ [<Ignore("Remove to run test")>]
12
+ let ``Basic`` () =
13
+ let phrase = "Portable Network Graphics"
14
+ let expected = "PNG"
15
+ let actual = acronym phrase
16
+ Assert.That(expected, Is.EqualTo(actual))
17
+
18
+ [<Test>]
19
+ [<Ignore("Remove to run test")>]
20
+ let ``Lowercase words`` () =
21
+ let phrase = "Ruby on Rails"
22
+ let expected = "ROR"
23
+ let actual = acronym phrase
24
+ Assert.That(expected, Is.EqualTo(actual))
25
+
26
+ [<Test>]
27
+ [<Ignore("Remove to run test")>]
28
+ let ``Camel case`` () =
29
+ let phrase = "HyperText Markup Language"
30
+ let expected = "HTML"
31
+ let actual = acronym phrase
32
+ Assert.That(expected, Is.EqualTo(actual))
33
+
34
+ [<Test>]
35
+ [<Ignore("Remove to run test")>]
36
+ let ``Punctuation`` () =
37
+ let phrase = "First In, First Out"
38
+ let expected = "FIFO"
39
+ let actual = acronym phrase
40
+ Assert.That(expected, Is.EqualTo(actual))
41
+
42
+ [<Test>]
43
+ [<Ignore("Remove to run test")>]
44
+ let ``All-Caps words`` () =
45
+ let phrase = "PHP: Hypertext Preprocessor"
46
+ let expected = "PHP"
47
+ let actual = acronym phrase
48
+ Assert.That(expected, Is.EqualTo(actual))
49
+
50
+ [<Test>]
51
+ [<Ignore("Remove to run test")>]
52
+ let ``Non-acronym all-caps word`` () =
53
+ let phrase = "GNU Image Manipulation Program"
54
+ let expected = "GIMP"
55
+ let actual = acronym phrase
56
+ Assert.That(expected, Is.EqualTo(actual))
57
+
58
+ [<Test>]
59
+ [<Ignore("Remove to run test")>]
60
+ let ``Hyphenated`` () =
61
+ let phrase = "Complementary metal-oxide semiconductor"
62
+ let expected = "CMOS"
63
+ let actual = acronym phrase
64
+ Assert.That(expected, Is.EqualTo(actual))
@@ -3,12 +3,65 @@ module AtbashTest
3
3
  open NUnit.Framework
4
4
  open Atbash
5
5
 
6
- [<TestCase("no", ExpectedResult = "ml")>]
7
- [<TestCase("yes", ExpectedResult = "bvh", Ignore = "Remove to run test case")>]
8
- [<TestCase("OMG", ExpectedResult = "lnt", Ignore = "Remove to run test case")>]
9
- [<TestCase("mindblowingly", ExpectedResult = "nrmwy oldrm tob", Ignore = "Remove to run test case")>]
10
- [<TestCase("Testing, 1 2 3, testing.", ExpectedResult = "gvhgr mt123 gvhgr mt", Ignore = "Remove to run test case")>]
11
- [<TestCase("Truth is fiction.", ExpectedResult = "gifgs rhurx grlm", Ignore = "Remove to run test case")>]
12
- [<TestCase("The quick brown fox jumps over the lazy dog.", ExpectedResult = "gsvjf rxpyi ldmul cqfnk hlevi gsvoz abwlt", Ignore = "Remove to run test case")>]
13
- let ``Encodes words using atbash cipher`` words =
14
- encode words
6
+ [<Test>]
7
+ let ``Encode yes`` () =
8
+ let phrase = "yes"
9
+ let expected = "bvh"
10
+ let actual = encode phrase
11
+ Assert.That(actual, Is.EqualTo(expected))
12
+
13
+ [<Test>]
14
+ [<Ignore("Remove to run test")>]
15
+ let ``Encode no`` () =
16
+ let phrase = "no"
17
+ let expected = "ml"
18
+ let actual = encode phrase
19
+ Assert.That(actual, Is.EqualTo(expected))
20
+
21
+ [<Test>]
22
+ [<Ignore("Remove to run test")>]
23
+ let ``Encode OMG`` () =
24
+ let phrase = "OMG"
25
+ let expected = "lnt"
26
+ let actual = encode phrase
27
+ Assert.That(actual, Is.EqualTo(expected))
28
+
29
+ [<Test>]
30
+ [<Ignore("Remove to run test")>]
31
+ let ``Encode spaces`` () =
32
+ let phrase = "O M G"
33
+ let expected = "lnt"
34
+ let actual = encode phrase
35
+ Assert.That(actual, Is.EqualTo(expected))
36
+
37
+ [<Test>]
38
+ [<Ignore("Remove to run test")>]
39
+ let ``Encode mindblowingly`` () =
40
+ let phrase = "mindblowingly"
41
+ let expected = "nrmwy oldrm tob"
42
+ let actual = encode phrase
43
+ Assert.That(actual, Is.EqualTo(expected))
44
+
45
+ [<Test>]
46
+ [<Ignore("Remove to run test")>]
47
+ let ``Encode numbers`` () =
48
+ let phrase = "Testing, 1 2 3, testing."
49
+ let expected = "gvhgr mt123 gvhgr mt"
50
+ let actual = encode phrase
51
+ Assert.That(actual, Is.EqualTo(expected))
52
+
53
+ [<Test>]
54
+ [<Ignore("Remove to run test")>]
55
+ let ``Encode deep thought`` () =
56
+ let phrase = "Truth is fiction."
57
+ let expected = "gifgs rhurx grlm"
58
+ let actual = encode phrase
59
+ Assert.That(actual, Is.EqualTo(expected))
60
+
61
+ [<Test>]
62
+ [<Ignore("Remove to run test")>]
63
+ let ``Encode all the letters`` () =
64
+ let phrase = "The quick brown fox jumps over the lazy dog."
65
+ let expected = "gsvjf rxpyi ldmul cqfnk hlevi gsvoz abwlt"
66
+ let actual = encode phrase
67
+ Assert.That(actual, Is.EqualTo(expected))
@@ -4,17 +4,28 @@ open System
4
4
  open NUnit.Framework
5
5
  open Clock
6
6
 
7
- [<TestCase(8, "08:00")>]
8
- [<TestCase(9, "09:00", Ignore = "Remove to run test case")>]
9
- let ``Prints the hour`` (hours: int, expected: string) =
10
- let clock = mkClock hours 0
11
- Assert.That(display clock, Is.EqualTo(expected))
12
-
13
- [<TestCase(11, 9, "11:09", Ignore = "Remove to run test case")>]
14
- [<TestCase(11, 19, "11:19", Ignore = "Remove to run test case")>]
15
- let ``Prints past the hour`` (hours: int) (minutes: int) (expected: string) =
16
- let clock = mkClock hours minutes
17
- Assert.That(display clock, Is.EqualTo(expected))
7
+ [<Test>]
8
+ let ``Prints 8 o'clock`` () =
9
+ let clock = mkClock 8 0
10
+ Assert.That(display clock, Is.EqualTo("08:00"))
11
+
12
+ [<Test>]
13
+ [<Ignore("Remove to run test")>]
14
+ let ``Prints 9 o'clock`` () =
15
+ let clock = mkClock 9 0
16
+ Assert.That(display clock, Is.EqualTo("09:00"))
17
+
18
+ [<Test>]
19
+ [<Ignore("Remove to run test")>]
20
+ let ``Can print single-digit minutes`` () =
21
+ let clock = mkClock 11 9
22
+ Assert.That(display clock, Is.EqualTo("11:09"))
23
+
24
+ [<Test>]
25
+ [<Ignore("Remove to run test")>]
26
+ let ``Can print double-digit minutes`` () =
27
+ let clock = mkClock 11 19
28
+ Assert.That(display clock, Is.EqualTo("11:19"))
18
29
 
19
30
  [<Test>]
20
31
  [<Ignore("Remove to run test")>]
@@ -1,4 +1,5 @@
1
1
  import org.junit.Test;
2
+ import org.junit.Ignore;
2
3
 
3
4
  import java.util.*;
4
5
 
@@ -27,6 +28,7 @@ public class EtlTest {
27
28
  assertEquals(expected, etl.transform(old));
28
29
  }
29
30
 
31
+ @Ignore
30
32
  @Test
31
33
  public void testTransformMoreValues() {
32
34
  Map<Integer, List<String>> old = new HashMap<Integer, List<String>>() {
@@ -50,6 +52,7 @@ public class EtlTest {
50
52
  assertEquals(expected, etl.transform(old));
51
53
  }
52
54
 
55
+ @Ignore
53
56
  @Test
54
57
  public void testMoreKeys() {
55
58
  Map<Integer, List<String>> old = new HashMap<Integer, List<String>>() {
@@ -73,6 +76,7 @@ public class EtlTest {
73
76
  assertEquals(expected, etl.transform(old));
74
77
  }
75
78
 
79
+ @Ignore
76
80
  @Test
77
81
  public void testFullDataset() {
78
82
  Map<Integer, List<String>> old = new HashMap<Integer, List<String>>() {
@@ -12,6 +12,12 @@ public class HelloWorldTest {
12
12
  assertEquals("Hello, World!", HelloWorld.hello(null));
13
13
  }
14
14
 
15
+ @Test
16
+ @Ignore
17
+ public void emptyStringIsComparedByValue() {
18
+ assertEquals("Hello, World!", HelloWorld.hello(new String("")));
19
+ }
20
+
15
21
  @Test
16
22
  @Ignore
17
23
  public void helloSampleName() {
@@ -99,15 +99,24 @@
99
99
  "arithmetics",
100
100
  "control-flow (conditionals)"
101
101
  ]
102
+ },
103
+ {
104
+ "slug": "atbash-cipher",
105
+ "difficulty": 1,
106
+ "topics": [
107
+ "strings",
108
+ "control-flow (conditionals)",
109
+ "control-flow (loops)"
110
+ ]
102
111
  },
103
112
  {
104
- "slug": "roman-numerals",
105
- "difficulty": 1,
106
- "topics": [
107
- "control-flow (loops)",
108
- "strings",
109
- "mathematics"
110
- ]
113
+ "slug": "roman-numerals",
114
+ "difficulty": 1,
115
+ "topics": [
116
+ "control-flow (loops)",
117
+ "strings",
118
+ "mathematics"
119
+ ]
111
120
  },
112
121
  {
113
122
  "slug": "isogram",
@@ -0,0 +1,8 @@
1
+ function encode(input::AbstractString)
2
+
3
+ end
4
+
5
+ function decode(input::AbstractString)
6
+
7
+ end
8
+
@@ -0,0 +1,4 @@
1
+ cipher(input::AbstractString) = map(x->isalpha(x)?Char(219-Int(x)):x, lowercase(filter(isalnum, input)))
2
+ encode(input::AbstractString) = join(matchall(r"(.{1,5})", cipher(input)), ' ')
3
+ decode(input::AbstractString) = cipher(input)
4
+
@@ -0,0 +1,56 @@
1
+ using Base.Test
2
+
3
+ include("atbash-cipher.jl")
4
+
5
+ @testset "encoding from English to atbash" begin
6
+ @testset "encode yes" begin
7
+ @test encode("yes") == "bvh"
8
+ end
9
+
10
+ @testset "encode no" begin
11
+ @test encode("no") == "ml"
12
+ end
13
+
14
+ @testset "encode OMG" begin
15
+ @test encode("OMG") == "lnt"
16
+ end
17
+
18
+ @testset "encode spaces" begin
19
+ @test encode("O M G") == "lnt"
20
+ end
21
+
22
+ @testset "encode mindblowingly" begin
23
+ @test encode("mindblowingly") == "nrmwy oldrm tob"
24
+ end
25
+
26
+ @testset "encode numbers" begin
27
+ @test encode("Testing,1 2 3, testing.") == "gvhgr mt123 gvhgr mt"
28
+ end
29
+
30
+ @testset "encode deep thought" begin
31
+ @test encode("Truth is fiction.") == "gifgs rhurx grlm"
32
+ end
33
+
34
+ @testset "encode all the letters" begin
35
+ @test encode("The quick brown fox jumps over the lazy dog.") == "gsvjf rxpyi ldmul cqfnk hlevi gsvoz abwlt"
36
+ end
37
+ end
38
+
39
+ @testset "decoding from atbash to English" begin
40
+ @testset "decode exercism" begin
41
+ @test decode("vcvix rhn") == "exercism"
42
+ end
43
+
44
+ @testset "decode a sentence" begin
45
+ @test decode("zmlyh gzxov rhlug vmzhg vkkrm thglm v") == "anobstacleisoftenasteppingstone"
46
+ end
47
+
48
+ @testset "decode numbers" begin
49
+ @test decode("gvhgr mt123 gvhgr mt") == "testing123testing"
50
+ end
51
+
52
+ @testset "decode all the letters" begin
53
+ @test decode("gsvjf rxpyi ldmul cqfnk hlevi gsvoz abwlt") == "thequickbrownfoxjumpsoverthelazydog"
54
+ end
55
+ end
56
+
@@ -222,6 +222,16 @@
222
222
  "difficulty": 1,
223
223
  "slug": "change",
224
224
  "topics": []
225
+ },
226
+ {
227
+ "difficulty": 10,
228
+ "slug": "react",
229
+ "topics": [
230
+ "Reactive programming",
231
+ "Generics",
232
+ "Nested classes",
233
+ "Higher-order functions"
234
+ ]
225
235
  }
226
236
  ]
227
237
  }
@@ -0,0 +1,28 @@
1
+ buildscript {
2
+ ext.kotlin_version = '1.0.6'
3
+ repositories {
4
+ mavenCentral()
5
+ }
6
+ dependencies {
7
+ classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
8
+ }
9
+ }
10
+
11
+ apply plugin: 'kotlin'
12
+
13
+ repositories {
14
+ mavenCentral()
15
+ }
16
+
17
+ dependencies {
18
+ compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
19
+
20
+ testCompile 'junit:junit:4.12'
21
+ testCompile "org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version"
22
+ }
23
+ test {
24
+ testLogging {
25
+ exceptionFormat = 'full'
26
+ events = ["passed", "failed", "skipped"]
27
+ }
28
+ }
@@ -0,0 +1,65 @@
1
+ class Reactor<T>() {
2
+ abstract inner class Cell {
3
+ abstract val value: T
4
+ internal val dependents = mutableListOf<ComputeCell>()
5
+ }
6
+
7
+ interface Subscription {
8
+ fun cancel()
9
+ }
10
+
11
+ inner class InputCell(initialValue: T) : Cell() {
12
+ override var value: T = initialValue
13
+ set(newValue) {
14
+ field = newValue
15
+ dependents.forEach { it.propagate() }
16
+ dependents.forEach { it.fireCallbacks() }
17
+ }
18
+ }
19
+
20
+ inner class ComputeCell private constructor(val newValue: () -> T) : Cell() {
21
+ override var value: T = newValue()
22
+ private set
23
+
24
+ private var lastCallbackValue = value
25
+ private var callbacksIssued = 0
26
+ private val activeCallbacks = mutableMapOf<Int, (T) -> Any>()
27
+
28
+ constructor(vararg cells: Cell, f: (List<T>) -> T) : this({ f(cells.map { it.value }) }) {
29
+ for (cell in cells) {
30
+ cell.dependents.add(this)
31
+ }
32
+ }
33
+
34
+ fun addCallback(f: (T) -> Any): Subscription {
35
+ val id = callbacksIssued
36
+ callbacksIssued++
37
+ activeCallbacks[id] = f
38
+ return object : Subscription {
39
+ override fun cancel() {
40
+ activeCallbacks.remove(id)
41
+ }
42
+ }
43
+ }
44
+
45
+ internal fun propagate() {
46
+ val nv = newValue()
47
+ if (nv == value) {
48
+ return
49
+ }
50
+ value = nv
51
+ dependents.forEach { it.propagate() }
52
+ }
53
+
54
+ internal fun fireCallbacks() {
55
+ if (value == lastCallbackValue) {
56
+ return
57
+ }
58
+ lastCallbackValue = value
59
+ for (cb in activeCallbacks.values) {
60
+ cb(value)
61
+ }
62
+ dependents.forEach { it.fireCallbacks() }
63
+ }
64
+ }
65
+ }
@@ -0,0 +1,7 @@
1
+ class Reactor<T>() {
2
+ // Your compute cell's addCallback method must return an object
3
+ // that implements the Subscription interface.
4
+ interface Subscription {
5
+ fun cancel()
6
+ }
7
+ }
@@ -0,0 +1,221 @@
1
+ import org.junit.Test
2
+ import org.junit.Ignore
3
+ import org.junit.runner.RunWith
4
+ import org.junit.runners.Parameterized
5
+ import kotlin.test.assertEquals
6
+
7
+ class ReactTest {
8
+ @Test
9
+ fun inputCellsHaveValue() {
10
+ val reactor = Reactor<Int>()
11
+ val input = reactor.InputCell(10)
12
+ assertEquals(10, input.value)
13
+ }
14
+
15
+ @Ignore
16
+ @Test
17
+ fun inputCellsValueCanBeSet() {
18
+ val reactor = Reactor<Int>()
19
+ val input = reactor.InputCell(4)
20
+ input.value = 20
21
+ assertEquals(20, input.value)
22
+ }
23
+
24
+ @Ignore
25
+ @Test
26
+ fun computeCellsCalculateInitialValue() {
27
+ val reactor = Reactor<Int>()
28
+ val input = reactor.InputCell(1)
29
+ val output = reactor.ComputeCell(input) { it[0] + 1 }
30
+ assertEquals(2, output.value)
31
+ }
32
+
33
+ @Ignore
34
+ @Test
35
+ fun computeCellsTakeInputsInTheRightOrder() {
36
+ val reactor = Reactor<Int>()
37
+ val one = reactor.InputCell(1)
38
+ val two = reactor.InputCell(2)
39
+ val output = reactor.ComputeCell(one, two) { it[0] + it[1] * 10 }
40
+ assertEquals(21, output.value)
41
+ }
42
+
43
+ @Ignore
44
+ @Test
45
+ fun computeCellsUpdateValueWhenDependenciesAreChanged() {
46
+ val reactor = Reactor<Int>()
47
+ val input = reactor.InputCell(1)
48
+ val output = reactor.ComputeCell(input) { it[0] + 1 }
49
+ input.value = 3
50
+ assertEquals(4, output.value)
51
+ }
52
+
53
+ @Ignore
54
+ @Test
55
+ fun computeCellsCanDependOnOtherComputeCells() {
56
+ val reactor = Reactor<Int>()
57
+ val input = reactor.InputCell(1)
58
+ val timesTwo = reactor.ComputeCell(input) { it[0] * 2 }
59
+ val timesThirty = reactor.ComputeCell(input) { it[0] * 30 }
60
+ val output = reactor.ComputeCell(timesTwo, timesThirty) { it[0] + it[1] }
61
+
62
+ assertEquals(32, output.value)
63
+ input.value = 3
64
+ assertEquals(96, output.value)
65
+ }
66
+
67
+ @Ignore
68
+ @Test
69
+ fun computeCellsFireCallbacks() {
70
+ val reactor = Reactor<Int>()
71
+ val input = reactor.InputCell(1)
72
+ val output = reactor.ComputeCell(input) { it[0] + 1 }
73
+
74
+ val vals = mutableListOf<Int>()
75
+ output.addCallback { vals.add(it) }
76
+
77
+ input.value = 3
78
+ assertEquals(listOf(4), vals)
79
+ }
80
+
81
+ @Ignore
82
+ @Test
83
+ fun callbacksOnlyFireOnChange() {
84
+ val reactor = Reactor<Int>()
85
+ val input = reactor.InputCell(1)
86
+ val output = reactor.ComputeCell(input) { if (it[0] < 3) 111 else 222 }
87
+
88
+ val vals = mutableListOf<Int>()
89
+ output.addCallback { vals.add(it) }
90
+
91
+ input.value = 2
92
+ assertEquals(listOf<Int>(), vals)
93
+
94
+ input.value = 4
95
+ assertEquals(listOf(222), vals)
96
+ }
97
+
98
+ @Ignore
99
+ @Test
100
+ fun callbacksCanBeAddedAndRemoved() {
101
+ val reactor = Reactor<Int>()
102
+ val input = reactor.InputCell(11)
103
+ val output = reactor.ComputeCell(input) { it[0] + 1 }
104
+
105
+ val vals1 = mutableListOf<Int>()
106
+ val sub1 = output.addCallback { vals1.add(it) }
107
+ val vals2 = mutableListOf<Int>()
108
+ output.addCallback { vals2.add(it) }
109
+
110
+ input.value = 31
111
+ sub1.cancel()
112
+
113
+ val vals3 = mutableListOf<Int>()
114
+ output.addCallback { vals3.add(it) }
115
+
116
+ input.value = 41
117
+
118
+ assertEquals(listOf(32), vals1)
119
+ assertEquals(listOf(32, 42), vals2)
120
+ assertEquals(listOf(42), vals3)
121
+ }
122
+
123
+ @Ignore
124
+ @Test
125
+ fun removingACallbackMultipleTimesDoesntInterfereWithOtherCallbacks() {
126
+ val reactor = Reactor<Int>()
127
+ val input = reactor.InputCell(1)
128
+ val output = reactor.ComputeCell(input) { it[0] + 1 }
129
+
130
+ val vals1 = mutableListOf<Int>()
131
+ val sub1 = output.addCallback { vals1.add(it) }
132
+ val vals2 = mutableListOf<Int>()
133
+ output.addCallback { vals2.add(it) }
134
+
135
+ for (i in 1..10) {
136
+ sub1.cancel()
137
+ }
138
+
139
+ input.value = 2
140
+ assertEquals(listOf<Int>(), vals1)
141
+ assertEquals(listOf(3), vals2)
142
+ }
143
+
144
+ @Ignore
145
+ @Test
146
+ fun callbacksShouldOnlyBeCalledOnceEvenIfMultipleDependenciesChange() {
147
+ val reactor = Reactor<Int>()
148
+ val input = reactor.InputCell(1)
149
+ val plusOne = reactor.ComputeCell(input) { it[0] + 1 }
150
+ val minusOne1 = reactor.ComputeCell(input) { it[0] - 1 }
151
+ val minusOne2 = reactor.ComputeCell(minusOne1) { it[0] - 1 }
152
+ val output = reactor.ComputeCell(plusOne, minusOne2) { it[0] * it[1] }
153
+
154
+ val vals = mutableListOf<Int>()
155
+ output.addCallback { vals.add(it) }
156
+
157
+ input.value = 4
158
+ assertEquals(listOf(10), vals)
159
+ }
160
+
161
+ @Ignore
162
+ @Test
163
+ fun callbacksShouldNotBeCalledIfDependenciesChangeButOutputValueDoesntChange() {
164
+ val reactor = Reactor<Int>()
165
+ val input = reactor.InputCell(1)
166
+ val plusOne = reactor.ComputeCell(input) { it[0] + 1 }
167
+ val minusOne = reactor.ComputeCell(input) { it[0] - 1 }
168
+ val alwaysTwo = reactor.ComputeCell(plusOne, minusOne) { it[0] - it[1] }
169
+
170
+ val vals = mutableListOf<Int>()
171
+ alwaysTwo.addCallback { vals.add(it) }
172
+
173
+ for (i in 1..10) {
174
+ input.value = i
175
+ }
176
+
177
+ assertEquals(listOf<Int>(), vals)
178
+ }
179
+ }
180
+
181
+ @RunWith(Parameterized::class)
182
+ // This is a digital logic circuit called an adder:
183
+ // https://en.wikipedia.org/wiki/Adder_(electronics)
184
+ class ReactAdderTest(val input: Input, val expected: Expected) {
185
+
186
+ companion object {
187
+ data class Input(val a: Boolean, val b: Boolean, val carryIn: Boolean)
188
+ data class Expected(val carryOut: Boolean, val sum: Boolean)
189
+
190
+ @JvmStatic
191
+ @Parameterized.Parameters(name = "{index}: {0} = {1}")
192
+ fun data() = listOf(
193
+ arrayOf(Input(a=false, b=false, carryIn=false), Expected(carryOut=false, sum=false)),
194
+ arrayOf(Input(a=false, b=false, carryIn=true), Expected(carryOut=false, sum=true)),
195
+ arrayOf(Input(a=false, b=true, carryIn=false), Expected(carryOut=false, sum=true)),
196
+ arrayOf(Input(a=false, b=true, carryIn=true), Expected(carryOut=true, sum=false)),
197
+ arrayOf(Input(a=true, b=false, carryIn=false), Expected(carryOut=false, sum=true)),
198
+ arrayOf(Input(a=true, b=false, carryIn=true), Expected(carryOut=true, sum=false)),
199
+ arrayOf(Input(a=true, b=true, carryIn=false), Expected(carryOut=true, sum=false)),
200
+ arrayOf(Input(a=true, b=true, carryIn=true), Expected(carryOut=true, sum=true))
201
+ )
202
+ }
203
+
204
+ @Ignore
205
+ @Test
206
+ fun test() {
207
+ val reactor = Reactor<Boolean>()
208
+ val a = reactor.InputCell(input.a)
209
+ val b = reactor.InputCell(input.b)
210
+ val carryIn = reactor.InputCell(input.carryIn)
211
+
212
+ val aXorB = reactor.ComputeCell(a, b) { it[0].xor(it[1]) }
213
+ val sum = reactor.ComputeCell(aXorB, carryIn) { it[0].xor(it[1]) }
214
+
215
+ val aXorBAndCin = reactor.ComputeCell(aXorB, carryIn) { it[0] && it[1] }
216
+ val aAndB = reactor.ComputeCell(a, b) { it[0] && it[1] }
217
+ val carryOut = reactor.ComputeCell(aXorBAndCin, aAndB) { it[0] || it[1] }
218
+
219
+ assertEquals(expected, Expected(sum=sum.value, carryOut=carryOut.value))
220
+ }
221
+ }
@@ -24,6 +24,7 @@ include 'pascals-triangle'
24
24
  include 'phone-number'
25
25
  include 'pig-latin'
26
26
  include 'raindrops'
27
+ include 'react'
27
28
  include 'rna-transcription'
28
29
  include 'robot-name'
29
30
  include 'roman-numerals'
data/tracks/lua/README.md CHANGED
@@ -4,44 +4,54 @@
4
4
 
5
5
  Exercism exercises in Lua
6
6
 
7
- ## Setup Dev environment for contributing
7
+ ## Setup dev environment for contributing
8
8
 
9
- ### Mac OS
9
+ Install Lua, Luarocks, and the Busted testing framework according to the
10
+ [installation instructions][1] for your platform.
10
11
 
11
- For Mac OS, you can use [homebrew][1] to install Lua and [luarocks][2]
12
+ To contribute a patch you will need a GitHub account and you will need to fork
13
+ the *exercism/xlua* repo to your account.
14
+ Clone your fork with the command: `git clone https://github.com/<your_username>/xlua`.
15
+ Create your patch and open a pull request to the exercism/xlua repo.
12
16
 
13
- $ brew install lua
17
+ See the GitHub Help for [forking a repo][2] and [creating a pull request][3]
18
+ if you are unfamiliar with this process.
14
19
 
15
- Then install [busted][3] testing framework for lua. Busted is similiar to Jasmine testing framework in Javascript.
20
+ To contribute a new exercise, create a folder named after the exercise within the
21
+ *xlua/exercises* directory. Create your files for a new test, test class and the implementation.
16
22
 
17
- $ luarocks install busted
23
+ For example, for the [Bob][4] exercise:
18
24
 
19
- Then create a folder for a new test, test class and the implementation.
25
+ $ tree bob
26
+ bob
27
+ ├── bob_spec.lua
28
+ └── bob.lua
20
29
 
21
- ls -l
22
- total 16
23
- -rw-r--r--@ 1 aarti staff 1111 Nov 25 14:05 bob_test.lua
24
- -rw-r--r--@ 1 aarti staff 453 Nov 25 14:05 bob.lua
30
+ 0 directories, 2 files
25
31
 
26
32
  Run the test
27
33
 
28
34
  $ busted .
29
35
 
30
- Rename bob.lua to example.lua, add test to config.json
36
+ Rename *bob.lua* to *example.lua*, and add the exercise to the [xlua/config.json][5] file.
31
37
 
32
- ls -l
33
- total 16
34
- -rw-r--r--@ 1 aarti staff 1111 Nov 25 14:05 bob_test.lua
35
- -rw-r--r--@ 1 aarti staff 453 Nov 25 14:05 example.lua
38
+ $ tree bob
39
+ bob
40
+ ├── bob_spec.lua
41
+ └── example.lua
36
42
 
37
- Other resources
38
-
39
- 1. [Lua Style Guide][4]
40
- 2. [Learn Lua in 15 minutes][5]
43
+ 0 directories, 2 files
41
44
 
42
45
  ## Contributing Guide
43
46
 
44
- Please see the [contributing guide](https://github.com/exercism/x-api/blob/master/CONTRIBUTING.md#the-exercise-data)
47
+ Please be familiar with the [contributing guide][6] in the x-common repository.
48
+ This describes how all the language tracks are put together, as well as details
49
+ about the common metadata, and high-level information about contributing to
50
+ existing problems and adding new problems.
51
+
52
+ ## Other Resources
53
+
54
+ Pleases see the [Useful Lua Resources][7] page.
45
55
 
46
56
  ## License
47
57
 
@@ -49,11 +59,13 @@ The MIT License (MIT)
49
59
 
50
60
  Copyright (c) 2014 Katrina Owen, _@kytrinyx.com
51
61
 
52
- ### Lua icon
62
+ ## Lua icon
53
63
  The Lua icon is inspired by the [Lua logo](http://www.lua.org/images/), which was designed by Alexandre Nakonechnyj.
54
64
 
55
- [1]: http://brew.sh/
56
- [2]: http://luarocks.org/
57
- [3]: http://olivinelabs.com/busted/
58
- [4]: https://github.com/Olivine-Labs/lua-style-guide
59
- [5]: http://tylerneylon.com/a/learn-lua/
65
+ [1]: http://exercism.io/languages/lua/installing
66
+ [2]: https://help.github.com/articles/fork-a-repo/
67
+ [3]: https://help.github.com/articles/creating-a-pull-request/
68
+ [4]: https://github.com/exercism/xlua/tree/master/exercises/bob
69
+ [5]: https://github.com/exercism/xlua/blob/master/config.json
70
+ [6]: https://github.com/exercism/x-common/blob/master/CONTRIBUTING.md
71
+ [7]: http://exercism.io/languages/lua/resources
@@ -5,7 +5,12 @@ There are many great free online resources for Lua including:
5
5
  3. For an official definition of the Lua language, consult the [Lua 5.1 Reference Manual][7], by R. Ierusalimschy, L. H. de Figueiredo, W. Celes.
6
6
  4. [Lua Style Guide][4]
7
7
  5. [Learn Lua in 15 minutes][5]
8
- 6. [Some][9] [options][10] [for][11] [linting][12]
8
+ 6. Some options for linting
9
+ - [lua-checker][9]
10
+ - [Lua Lint][10]
11
+ - [Lua Inspect][11]
12
+ - [luacheck][12]
13
+ - [Detecting Undefined Variables][13]
9
14
 
10
15
  [4]: https://github.com/Olivine-Labs/lua-style-guide
11
16
  [5]: http://tylerneylon.com/a/learn-lua/
@@ -15,4 +20,5 @@ There are many great free online resources for Lua including:
15
20
  [9]: https://code.google.com/p/lua-checker/
16
21
  [10]: http://lua-users.org/wiki/LuaLint
17
22
  [11]: http://lua-users.org/wiki/LuaInspect
18
- [12]: http://lua-users.org/wiki/DetectingUndefinedVariables
23
+ [12]: https://github.com/mpeterv/luacheck
24
+ [13]: http://lua-users.org/wiki/DetectingUndefinedVariables
@@ -1,5 +1,6 @@
1
1
  pub fn is_valid(candidate: &str) -> bool {
2
- if candidate.chars().any(|c| c.is_alphabetic()) || candidate.chars().count() == 1 {
2
+ if candidate.chars().filter(|c| c.is_digit(10)).take(2).count() <= 1 ||
3
+ candidate.chars().any(|c| !c.is_digit(10) && c != ' ') {
3
4
  return false;
4
5
  }
5
6
 
@@ -13,6 +13,12 @@ fn single_zero_string_is_invalid() {
13
13
  assert!(!is_valid("0"));
14
14
  }
15
15
 
16
+ #[test]
17
+ #[ignore]
18
+ fn simple_valid_sin() {
19
+ assert!(is_valid(" 5 9 "));
20
+ }
21
+
16
22
  #[test]
17
23
  #[ignore]
18
24
  fn valid_canadian_sin_is_valid() {
@@ -36,3 +42,39 @@ fn invalid_credit_card_is_invalid() {
36
42
  fn strings_that_contain_non_digits_are_invalid() {
37
43
  assert!(!is_valid("046a 454 286"));
38
44
  }
45
+
46
+ #[test]
47
+ #[ignore]
48
+ fn punctuation_is_invalid() {
49
+ assert!(!is_valid("055-444-285"));
50
+ }
51
+
52
+ #[test]
53
+ #[ignore]
54
+ fn symbols_are_invalid() {
55
+ assert!(!is_valid("055£ 444$ 285"));
56
+ }
57
+
58
+ #[test]
59
+ #[ignore]
60
+ fn single_digit_with_space_is_invalid() {
61
+ assert!(!is_valid(" 0"));
62
+ }
63
+
64
+ #[test]
65
+ #[ignore]
66
+ fn lots_of_zeros_are_valid() {
67
+ assert!(is_valid(" 00000"));
68
+ }
69
+
70
+ #[test]
71
+ #[ignore]
72
+ fn another_valid_sin() {
73
+ assert!(is_valid("055 444 285"));
74
+ }
75
+
76
+ #[test]
77
+ #[ignore]
78
+ fn nine_doubled_is_nine() {
79
+ assert!(is_valid("091"));
80
+ }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: trackler
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.6.35
4
+ version: 2.0.6.36
5
5
  platform: ruby
6
6
  authors:
7
7
  - Katrina Owen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-02-09 00:00:00.000000000 Z
11
+ date: 2017-02-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubyzip
@@ -4274,6 +4274,9 @@ files:
4274
4274
  - tracks/julia/exercises/anagram/anagram.jl
4275
4275
  - tracks/julia/exercises/anagram/example.jl
4276
4276
  - tracks/julia/exercises/anagram/runtests.jl
4277
+ - tracks/julia/exercises/atbash-cipher/atbash-cipher.jl
4278
+ - tracks/julia/exercises/atbash-cipher/example.jl
4279
+ - tracks/julia/exercises/atbash-cipher/runtests.jl
4277
4280
  - tracks/julia/exercises/bob/bob.jl
4278
4281
  - tracks/julia/exercises/bob/example.jl
4279
4282
  - tracks/julia/exercises/bob/runtests.jl
@@ -4485,6 +4488,10 @@ files:
4485
4488
  - tracks/kotlin/exercises/raindrops/src/example/kotlin/Raindrops.kt
4486
4489
  - tracks/kotlin/exercises/raindrops/src/main/kotlin/.keep
4487
4490
  - tracks/kotlin/exercises/raindrops/src/test/kotlin/RaindropsTest.kt
4491
+ - tracks/kotlin/exercises/react/build.gradle
4492
+ - tracks/kotlin/exercises/react/src/example/kotlin/React.kt
4493
+ - tracks/kotlin/exercises/react/src/main/kotlin/React.kt
4494
+ - tracks/kotlin/exercises/react/src/test/kotlin/ReactTest.kt
4488
4495
  - tracks/kotlin/exercises/rna-transcription/build.gradle
4489
4496
  - tracks/kotlin/exercises/rna-transcription/src/example/kotlin/RnaTranscription.kt
4490
4497
  - tracks/kotlin/exercises/rna-transcription/src/main/kotlin/RnaTranscription.kt
@@ -4874,7 +4881,6 @@ files:
4874
4881
  - tracks/lua/.travis.yml
4875
4882
  - tracks/lua/LICENSE
4876
4883
  - tracks/lua/README.md
4877
- - tracks/lua/SETUP.md
4878
4884
  - tracks/lua/bin/fetch-configlet
4879
4885
  - tracks/lua/bin/test-all
4880
4886
  - tracks/lua/config.json
data/tracks/lua/SETUP.md DELETED
@@ -1,76 +0,0 @@
1
- ### Getting started
2
- #### MacOS
3
- First install Lua and [Luarocks][2] using [Homebrew][1]:
4
-
5
- ```shell
6
- $ brew install lua
7
- ```
8
-
9
- Then install the [Busted][3] testing framework for Lua:
10
-
11
- ```shell
12
- $ luarocks install busted
13
- ```
14
-
15
- Then run your tests:
16
-
17
- ```shell
18
- $ busted .
19
- ```
20
-
21
- #### Ubuntu
22
- First install Lua and [Luarocks][2] using [Apt][6]:
23
-
24
- ```shell
25
- $ sudo apt-get install lua5.3 luarocks
26
- ```
27
-
28
- Then install the [Busted][3] testing framework for Lua:
29
-
30
- ```shell
31
- $ luarocks install busted
32
- ```
33
-
34
- If this fails, you may need to use `sudo`:
35
-
36
- ```shell
37
- $ sudo luarocks install busted
38
- ```
39
-
40
- Then run your tests:
41
-
42
- ```shell
43
- $ busted .
44
- ```
45
-
46
- #### Windows
47
- First install Lua and [Luarocks][2] using [Chocolatey][7]:
48
-
49
- ```
50
- C:\> choco install lua
51
- ```
52
-
53
- Then install the [Busted][3] testing framework for Lua:
54
-
55
- ```
56
- C:\> luarocks install busted
57
- ```
58
-
59
- Then run your tests:
60
-
61
- ```
62
- C:\> busted .
63
- ```
64
-
65
- #### Other resources
66
-
67
- 1. [Lua Style Guide][4]
68
- 2. [Learn Lua in 15 minutes][5]
69
-
70
- [1]: http://brew.sh/
71
- [2]: http://luarocks.org/
72
- [3]: http://olivinelabs.com/busted/
73
- [4]: https://github.com/Olivine-Labs/lua-style-guide
74
- [5]: http://tylerneylon.com/a/learn-lua/
75
- [6]: https://help.ubuntu.com/lts/serverguide/apt.html
76
- [7]: http://chocolatey.org/