Skip to content

Commit

Permalink
Merge pull request #58 from NerdWallet/android-separation
Browse files Browse the repository at this point in the history
Add support for Android-compliant builds
  • Loading branch information
MarkusAmshove authored Sep 5, 2017
2 parents 8ff3fad + 3b33ddc commit 3913e09
Show file tree
Hide file tree
Showing 18 changed files with 909 additions and 590 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ out/
.classpath
.project
bin/
.settings/
.settings/
local.properties
24 changes: 21 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ apply plugin: 'maven'
apply plugin: 'maven-publish'
apply plugin: 'com.jfrog.bintray'

def isAndroid = project.rootProject.hasProperty("ANDROID")

repositories {
jcenter()
maven {
Expand All @@ -39,8 +41,24 @@ dependencies {
}

sourceSets {
main.kotlin.srcDirs += 'src/main/kotlin'
test.kotlin.srcDirs += 'src/test/kotlin'
main {
kotlin {
srcDirs += 'src/main/kotlin'

if(isAndroid) {
exclude '**/*Backtick.kt'
}
}
}
test {
kotlin {
srcDirs += 'src/test/kotlin'

if(isAndroid) {
exclude '**/backtick*/**'
}
}
}
}

task sourcesJar(type: Jar, dependsOn: classes) {
Expand Down Expand Up @@ -71,7 +89,7 @@ publishing {
PublishKluent(MavenPublication) {
from components.java
groupId 'org.amshove.kluent'
artifactId 'kluent'
artifactId isAndroid ? 'kluent-android' : 'kluent'
version project.version

// http://stackoverflow.com/a/32353697/6556970
Expand Down
42 changes: 14 additions & 28 deletions src/main/kotlin/org/amshove/kluent/Basic.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,44 +3,30 @@ package org.amshove.kluent
import org.junit.Assert.*
import kotlin.reflect.KClass

infix fun Any?.`should equal`(theOther: Any?) = assertEquals(theOther, this)
infix fun Any?.shouldEqual(theOther: Any?) = this `should equal` theOther
infix fun Any?.shouldEqual(theOther: Any?) = assertEquals(theOther, this)

infix fun Any?.`should not equal`(theOther: Any?) = assertNotEquals(theOther, this)
infix fun Any?.shouldNotEqual(theOther: Any?) = this `should not equal` theOther
infix fun Any?.shouldNotEqual(theOther: Any?) = assertNotEquals(theOther, this)

infix fun Any?.`should be`(theOther: Any?) = assertSame(theOther, this)
infix fun Any?.shouldBe(theOther: Any?) = this `should be` theOther
infix fun Any?.shouldBe(theOther: Any?) = assertSame(theOther, this)

infix fun Any?.`should not be`(theOther: Any?) = assertNotSame(theOther, this)
infix fun Any?.shouldNotBe(theOther: Any?) = this `should not be` theOther
infix fun Any?.shouldNotBe(theOther: Any?) = assertNotSame(theOther, this)

infix fun Any?.`should be instance of`(className: Class<*>) = assertTrue("Expected $this to be an instance of $className", className.isInstance(this))
infix fun Any?.shouldBeInstanceOf(className: Class<*>) = this `should be instance of` className
infix fun Any?.shouldBeInstanceOf(className: Class<*>) = assertTrue("Expected $this to be an instance of $className", className.isInstance(this))

infix fun Any?.`should be instance of`(className: KClass<*>) = assertTrue("Expected $this to be an instance of $className", className.isInstance(this))
infix fun Any?.shouldBeInstanceOf(className: KClass<*>) = this `should be instance of` className
infix fun Any?.shouldBeInstanceOf(className: KClass<*>) = assertTrue("Expected $this to be an instance of $className", className.isInstance(this))

infix fun Any?.`should not be instance of`(className: Class<*>) = assertFalse("Expected $this to not be an instance of $className", className.isInstance(this))
infix fun Any?.shouldNotBeInstanceOf(className: Class<*>) = this `should not be instance of` className
infix fun Any?.shouldNotBeInstanceOf(className: Class<*>) = assertFalse("Expected $this to not be an instance of $className", className.isInstance(this))

infix fun Any?.`should not be instance of`(className: KClass<*>) = assertFalse("Expected $this to not be an instance of $className", className.isInstance(this))
infix fun Any?.shouldNotBeInstanceOf(className: KClass<*>) = this `should not be instance of` className
infix fun Any?.shouldNotBeInstanceOf(className: KClass<*>) = assertFalse("Expected $this to not be an instance of $className", className.isInstance(this))

fun Any?.`should be null`() = assertNull(this)
fun Any?.shouldBeNull() = this.`should be null`()
fun Any?.shouldBeNull() = assertNull(this)

fun Any?.`should not be null`() = assertNotNull(this)
fun Any?.shouldNotBeNull() = this.`should not be null`()
fun Any?.shouldNotBeNull() = assertNotNull(this)

fun Boolean.`should be true`() = assertTrue(this)
fun Boolean.shouldBeTrue() = this.`should be true`()
fun Boolean.shouldBeTrue() = assertTrue(this)

fun Boolean.`should be false`() = assertFalse(this)
fun Boolean.shouldBeFalse() = this.`should be false`()
fun Boolean.shouldBeFalse() = assertFalse(this)

fun Boolean.`should not be true`() = this.`should be false`()
fun Boolean.shouldNotBeTrue() = this.`should not be true`()
fun Boolean.shouldNotBeTrue() = this.shouldBeFalse()

fun Boolean.`should not be false`() = this.`should be true`()
fun Boolean.shouldNotBeFalse() = this.`should not be false`()
fun Boolean.shouldNotBeFalse() = this.shouldBeTrue()
31 changes: 31 additions & 0 deletions src/main/kotlin/org/amshove/kluent/BasicBacktick.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package org.amshove.kluent

import kotlin.reflect.KClass

infix fun Any?.`should equal`(theOther: Any?) = this.shouldEqual(theOther)

infix fun Any?.`should not equal`(theOther: Any?) = this.shouldNotEqual(theOther)

infix fun Any?.`should be`(theOther: Any?) = this.shouldBe(theOther)

infix fun Any?.`should not be`(theOther: Any?) = this.shouldNotBe(theOther)

infix fun Any?.`should be instance of`(className: Class<*>) = this.shouldBeInstanceOf(className)

infix fun Any?.`should be instance of`(className: KClass<*>) = this.shouldBeInstanceOf(className)

infix fun Any?.`should not be instance of`(className: Class<*>) = this.shouldNotBeInstanceOf(className)

infix fun Any?.`should not be instance of`(className: KClass<*>) = this.shouldNotBeInstanceOf(className)

fun Any?.`should be null`() = this.shouldBeNull()

fun Any?.`should not be null`() = this.shouldNotBeNull()

fun Boolean.`should be true`() = this.shouldBeTrue()

fun Boolean.`should be false`() = this.shouldBeFalse()

fun Boolean.`should not be true`() = this.shouldBeFalse()

fun Boolean.`should not be false`() = this.shouldBeTrue()
68 changes: 24 additions & 44 deletions src/main/kotlin/org/amshove/kluent/CharSequence.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,68 +2,48 @@ package org.amshove.kluent

import org.junit.Assert.*

infix fun CharSequence.`should start with`(theOther: CharSequence) = assertTrue("Expected the CharSequence $this to start with $theOther", this.startsWith(theOther))
infix fun CharSequence.shouldStartWith(theOther: CharSequence) = this `should start with` theOther
infix fun CharSequence.shouldStartWith(theOther: CharSequence) = assertTrue("Expected the CharSequence $this to start with $theOther", this.startsWith(theOther))

infix fun CharSequence.`should end with`(theOther: CharSequence) = assertTrue("Expected the CharSequence $this to end with $theOther", this.endsWith(theOther))
infix fun CharSequence.shouldEndWith(theOther: CharSequence) = this `should end with` theOther
infix fun CharSequence.shouldEndWith(theOther: CharSequence) = assertTrue("Expected the CharSequence $this to end with $theOther", this.endsWith(theOther))

infix fun CharSequence.`should contain`(theOther: CharSequence) = assertTrue("Expected the CharSequence $this to contain $theOther", this.contains(theOther))
infix fun CharSequence.shouldContain(theOther: CharSequence) = this `should contain` theOther
infix fun CharSequence.shouldContain(theOther: CharSequence) = assertTrue("Expected the CharSequence $this to contain $theOther", this.contains(theOther))

infix fun CharSequence.`should match`(regex: String) = assertTrue("Expected $this to match $regex", this.matches(Regex(regex)))
infix fun CharSequence.shouldMatch(regex: String) = this `should match` regex
infix fun CharSequence.shouldMatch(regex: String) = assertTrue("Expected $this to match $regex", this.matches(Regex(regex)))

infix fun CharSequence.`should match`(regex: Regex) = assertTrue("Expected $this to match ${regex.pattern}", this.matches(regex))
infix fun CharSequence.shouldMatch(regex: Regex) = this `should match` regex
infix fun CharSequence.shouldMatch(regex: Regex) = assertTrue("Expected $this to match ${regex.pattern}", this.matches(regex))

fun CharSequence.`should be empty`() = assertTrue("Expected the CharSequence to be empty, but was $this", this.isEmpty())
fun CharSequence.shouldBeEmpty() = this.`should be empty`()
fun CharSequence.shouldBeEmpty() = assertTrue("Expected the CharSequence to be empty, but was $this", this.isEmpty())

fun CharSequence?.`should be null or empty`() = assertTrue("Expected $this to be null or empty", this == null || this.isEmpty())
fun CharSequence?.shouldBeNullOrEmpty() = this.`should be null or empty`()
fun CharSequence?.shouldBeNullOrEmpty() = assertTrue("Expected $this to be null or empty", this == null || this.isEmpty())

fun CharSequence.`should be blank`() = assertTrue("Expected the CharSequence to be blank, but was $this", this.isBlank())
fun CharSequence.shouldBeBlank() = this.`should be blank`()
fun CharSequence.shouldBeBlank() = assertTrue("Expected the CharSequence to be blank, but was $this", this.isBlank())

fun CharSequence?.`should be null or blank`() = assertTrue("Expected $this to be null or blank", this == null || this.isBlank())
fun CharSequence?.shouldBeNullOrBlank() = this.`should be null or blank`()
fun CharSequence?.shouldBeNullOrBlank() = assertTrue("Expected $this to be null or blank", this == null || this.isBlank())

infix fun String.`should equal to`(theOther: String) = assertEquals(theOther, this)
infix fun String.shouldEqualTo(theOther: String) = this `should equal to` theOther
infix fun String.shouldEqualTo(theOther: String) = assertEquals(theOther, this)

infix fun String.`should not equal to`(theOther: String) = assertNotEquals(theOther, this)
infix fun String.shouldNotEqualTo(theOther: String) = this `should not equal to` theOther
infix fun String.shouldNotEqualTo(theOther: String) = assertNotEquals(theOther, this)

infix fun CharSequence.`should not start with`(theOther: CharSequence) = assertFalse("Expected the CharSequence $this to not start with $theOther", this.startsWith(theOther))
infix fun CharSequence.shouldNotStartWith(theOther: CharSequence) = this `should not start with` theOther
infix fun CharSequence.shouldNotStartWith(theOther: CharSequence) =assertFalse("Expected the CharSequence $this to not start with $theOther", this.startsWith(theOther))

infix fun CharSequence.`should not end with`(theOther: CharSequence) = assertFalse("Expected the CharSequence $this to not end with $theOther", this.endsWith(theOther))
infix fun CharSequence.shouldNotEndWith(theOther: CharSequence) = this `should not end with` theOther
infix fun CharSequence.shouldNotEndWith(theOther: CharSequence) = assertFalse("Expected the CharSequence $this to not end with $theOther", this.endsWith(theOther))

infix fun CharSequence.`should not contain`(theOther: CharSequence) = assertFalse("Expected the CharSequence $this to not contain $theOther", this.contains(theOther))
infix fun CharSequence.shouldNotContain(theOther: CharSequence) = this `should not contain` theOther
infix fun CharSequence.shouldNotContain(theOther: CharSequence) = assertFalse("Expected the CharSequence $this to not contain $theOther", this.contains(theOther))

infix fun CharSequence.`should not match`(regex: String) = assertFalse("Expected $this to not match $regex", this.matches(Regex(regex)))
infix fun CharSequence.shouldNotMatch(regex: String) = this `should not match` regex
infix fun CharSequence.shouldNotMatch(regex: String) = assertFalse("Expected $this to not match $regex", this.matches(Regex(regex)))

infix fun CharSequence.`should not match`(regex: Regex) = assertFalse("Expected $this to not match ${regex.pattern}", this.matches(regex))
infix fun CharSequence.shouldNotMatch(regex: Regex) = this `should not match` regex
infix fun CharSequence.shouldNotMatch(regex: Regex) = assertFalse("Expected $this to not match ${regex.pattern}", this.matches(regex))

fun CharSequence.`should not be empty`() = assertTrue("Expected the CharSequence to not be empty", this.isNotEmpty())
fun CharSequence.shouldNotBeEmpty() = this.`should not be empty`()
fun CharSequence.shouldNotBeEmpty() = assertTrue("Expected the CharSequence to not be empty", this.isNotEmpty())

fun CharSequence?.`should not be null or empty`() {
this.`should not be null`()
this!!.`should not be empty`()
fun CharSequence?.shouldNotBeNullOrEmpty() {
this.shouldNotBeNull()
this!!.shouldNotBeEmpty()
}
fun CharSequence?.shouldNotBeNullOrEmpty() = this.`should not be null or empty`()

fun CharSequence.`should not be blank`() = assertTrue("Expected the CharSequence to not be blank", this.isNotBlank())
fun CharSequence.shouldNotBeBlank() = this.`should not be blank`()
fun CharSequence.shouldNotBeBlank() = assertTrue("Expected the CharSequence to not be blank", this.isNotBlank())

fun CharSequence?.`should not be null or blank`() {
this.`should not be null`()
this!!.`should not be blank`()
fun CharSequence?.shouldNotBeNullOrBlank() {
this.shouldNotBeNull()
this!!.shouldNotBeBlank()
}
fun CharSequence?.shouldNotBeNullOrBlank() = this.`should not be null or blank`()
41 changes: 41 additions & 0 deletions src/main/kotlin/org/amshove/kluent/CharSequenceBacktick.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package org.amshove.kluent

infix fun CharSequence.`should start with`(theOther: CharSequence) = this.shouldStartWith(theOther)

infix fun CharSequence.`should end with`(theOther: CharSequence) = this.shouldEndWith(theOther)

infix fun CharSequence.`should contain`(theOther: CharSequence) = this.shouldContain(theOther)

infix fun CharSequence.`should match`(regex: String) = this.shouldMatch(regex)

infix fun CharSequence.`should match`(regex: Regex) = this.shouldMatch(regex)

fun CharSequence.`should be empty`() = this.shouldBeEmpty()

fun CharSequence?.`should be null or empty`() = this.shouldBeNullOrEmpty()

fun CharSequence.`should be blank`() = this.shouldBeBlank()

fun CharSequence?.`should be null or blank`() = this.shouldBeNullOrBlank()

infix fun String.`should equal to`(theOther: String) = this.shouldEqualTo(theOther)

infix fun String.`should not equal to`(theOther: String) = this.shouldNotEqualTo(theOther)

infix fun CharSequence.`should not start with`(theOther: CharSequence) = this.shouldNotStartWith(theOther)

infix fun CharSequence.`should not end with`(theOther: CharSequence) = this.shouldNotEndWith(theOther)

infix fun CharSequence.`should not contain`(theOther: CharSequence) = this.shouldNotContain(theOther)

infix fun CharSequence.`should not match`(regex: String) = this.shouldNotMatch(regex)

infix fun CharSequence.`should not match`(regex: Regex) = this.shouldNotMatch(regex)

fun CharSequence.`should not be empty`() = this.shouldNotBeEmpty()

fun CharSequence?.`should not be null or empty`() = this.shouldNotBeNullOrEmpty()

fun CharSequence.`should not be blank`() = this.shouldNotBeBlank()

fun CharSequence?.`should not be null or blank`() = this.shouldNotBeNullOrBlank()
Loading

0 comments on commit 3913e09

Please sign in to comment.