Permalink
Browse files

License adde into comments

  • Loading branch information...
1 parent dfedf12 commit 907824ed139ea8bef5b071cb71cddda03b3a27f2 @danseid committed Nov 20, 2012
@@ -1,13 +1,25 @@
+/*
+ * Copyright 2012 Daniel Seidler
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package spec.matchers
import kotlin.test.*
/**
- * Created with IntelliJ IDEA.
- * User: m2909
- * Date: 15.11.12
- * Time: 08:39
- * To change this template use File | Settings | File Templates.
+ * @author Daniel Seidler
+ * @since 2012/11/19
*/
trait Matcher {
@@ -1,12 +1,25 @@
+/*
+ * Copyright 2012 Daniel Seidler
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package spec.matchers
/**
- * Created with IntelliJ IDEA.
- * User: m2909
- * Date: 19.11.12
- * Time: 09:51
- * To change this template use File | Settings | File Templates.
+ * @author Daniel Seidler
+ * @since 2012/11/20
*/
+
class FunctionFailMatcher<R>(val target: () -> R): Matcher{
fun with(error: Throwable) {
var failed = true // assume it will fail
@@ -1,14 +1,29 @@
+/*
+ * Copyright 2012 Daniel Seidler
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package spec.matchers
-/**.
- * User: Daniel Seidler
- * Date: 15.11.12
- * Time: 15:20
- */
import kotlin.test.*
+/**
+ * @author Daniel Seidler
+ * @since 2012/11/20
+ */
-inline fun <T>fail(expected: T, got: T) : Unit {
+inline fun <T>fail(expected: T, got: T): Unit {
fail("""
expected: <$expected>
got: <$got>
@@ -1,12 +1,25 @@
+/*
+ * Copyright 2012 Daniel Seidler
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package spec.matchers
-/**.
- * User: Daniel Seidler
- * Date: 15.11.12
- * Time: 12:21
+/**
+ * @author Daniel Seidler
+ * @since 2012/11/20
*/
-
-class IntMatcher(target: Int) : Matcher{
+class IntMatcher(target: Int): Matcher{
// greater than: target > value
fun gt(value: Int) {
@@ -15,7 +28,7 @@ class IntMatcher(target: Int) : Matcher{
// greater than or equal: target > value
fun gte(value: Int) {
- greaterOrEqualThan(value)
+ greaterOrEqualThan(value)
}
// less than: target > value
@@ -1,17 +1,31 @@
+/*
+ * Copyright 2012 Daniel Seidler
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package spec.matchers
-/**.
- * User: Daniel Seidler
- * Date: 15.11.12
- * Time: 12:22
+/**
+ * @author Daniel Seidler
+ * @since 2012/11/20
+ * Should Matcher Functions
*/
-/* SHOULD MATCHER*/
-// ANY
+// Any should be
public fun <T>T.should(val verb: BE): AnyBeMatcher<T> = AnyBeMatcher(this)
public fun <T>T.should(val verb: NOTBE): AnyNotBeMatcher<T> = AnyNotBeMatcher(this)
-//STRING
+// String should have | start | end | contain
public fun String.should(val verb: HAVE): StringHaveMatcher = StringHaveMatcher(this)
public fun String.should(val verb: NOTHAVE): StringNotHaveMatcher = StringNotHaveMatcher(this)
public fun String.should(val verb: START): StringStartMatcher = StringStartMatcher(this)
@@ -21,6 +35,6 @@ public fun String.should(val verb: NOTEND): StringNotEndMatcher = StringNotEndMa
public fun String.should(val verb: CONTAIN): StringContainMatcher = StringContainMatcher(this)
public fun String.should(val verb: NOTCONTAIN): StringNotContainMatcher = StringNotContainMatcher(this)
-//FUNCTION
+//() -> Unit should fail
public fun <R>jet.Function0<R>.should(verb: FAIL): FunctionFailMatcher<R> = FunctionFailMatcher(this)
public fun <R>jet.Function0<R>.should(verb: NOTFAIL): FunctionNotFailMatcher<R> = FunctionNotFailMatcher(this)
@@ -1,9 +1,23 @@
+/*
+ * Copyright 2012 Daniel Seidler
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package spec.matchers
-/**.
- * User: Daniel Seidler
- * Date: 15.11.12
- * Time: 13:11
+/**
+ * @author Daniel Seidler
+ * @since 2012/11/20
*/
class StringHaveMatcher(val target: String): Matcher{
@@ -1,10 +1,26 @@
+/*
+ * Copyright 2012 Daniel Seidler
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package spec.matchers
/**
- * User: Daniel Seidler
- * Date: 15.11.12
- * Time: 08:40
- *
+ * @author Daniel Seidler
+ * @since 2012/11/20
+ * Verb: an object that will be passed to a should function: <expression>.should(<verb>)
+ * using an infix notation it will be written like this: <expression> should verb
+ * example: string should be
*/
trait Verb {
}
@@ -52,6 +68,7 @@ public class NOTFAIL: Verb {
fun not() = fail
}
+/* VALUES */
val be = BE()
val notbe = NOTBE()
val have = HAVE()

0 comments on commit 907824e

Please sign in to comment.