Merge pull request #11 from bnorm/bn/multiplatform
Update sample to be a multiplatform project
This commit is contained in:
+68
-9
@@ -1,11 +1,11 @@
|
|||||||
buildscript {
|
buildscript {
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath("gradle.plugin.com.bnorm.power:kotlin-power-assert-gradle:0.2.0")
|
classpath("gradle.plugin.com.bnorm.power:kotlin-power-assert-gradle:0.3.0")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
kotlin("jvm") version "1.3.70"
|
kotlin("multiplatform") version "1.3.70"
|
||||||
}
|
}
|
||||||
apply(plugin = "com.bnorm.power.kotlin-power-assert")
|
apply(plugin = "com.bnorm.power.kotlin-power-assert")
|
||||||
|
|
||||||
@@ -13,14 +13,73 @@ repositories {
|
|||||||
mavenCentral()
|
mavenCentral()
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
|
||||||
implementation(kotlin("stdlib-jdk8"))
|
|
||||||
testImplementation(kotlin("test-junit"))
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks.compileTestKotlin {
|
kotlin {
|
||||||
kotlinOptions.jvmTarget = "1.8"
|
jvm {
|
||||||
kotlinOptions.useIR = true
|
compilations.all {
|
||||||
|
kotlinOptions {
|
||||||
|
kotlinOptions.jvmTarget = "1.8"
|
||||||
|
kotlinOptions.useIR = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
js {
|
||||||
|
browser()
|
||||||
|
nodejs()
|
||||||
|
|
||||||
|
compilations.all {
|
||||||
|
kotlinOptions {
|
||||||
|
kotlinOptions.freeCompilerArgs += listOf("-Xir-produce-klib-dir", "-Xir-produce-js")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
val osName = System.getProperty("os.name")
|
||||||
|
when {
|
||||||
|
"Windows" in osName -> mingwX64("native")
|
||||||
|
"Mac OS" in osName -> macosX64("native")
|
||||||
|
else -> linuxX64("native")
|
||||||
|
}
|
||||||
|
|
||||||
|
sourceSets {
|
||||||
|
val commonMain by getting {
|
||||||
|
dependencies {
|
||||||
|
implementation(kotlin("stdlib"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
val commonTest by getting {
|
||||||
|
dependencies {
|
||||||
|
implementation(kotlin("test-common"))
|
||||||
|
implementation(kotlin("test-annotations-common"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
val jvmMain by getting {
|
||||||
|
dependencies {
|
||||||
|
implementation(kotlin("stdlib-jdk8"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
val jvmTest by getting {
|
||||||
|
dependencies {
|
||||||
|
implementation(kotlin("test-junit"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
val jsMain by getting {
|
||||||
|
dependencies {
|
||||||
|
implementation(kotlin("stdlib-js"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
val jsTest by getting {
|
||||||
|
dependencies {
|
||||||
|
implementation(kotlin("test-js"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
val nativeMain by getting {
|
||||||
|
dependsOn(commonMain)
|
||||||
|
}
|
||||||
|
val nativeTest by getting {
|
||||||
|
dependsOn(commonTest)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
configure<com.bnorm.power.PowerAssertGradleExtension> {
|
configure<com.bnorm.power.PowerAssertGradleExtension> {
|
||||||
|
|||||||
@@ -0,0 +1,26 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2020 Brian Norman
|
||||||
|
*
|
||||||
|
* 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 com.bnorm.power
|
||||||
|
|
||||||
|
data class Person(
|
||||||
|
val firstName: String,
|
||||||
|
val lastName: String
|
||||||
|
) {
|
||||||
|
companion object {
|
||||||
|
val UNKNOWN = listOf(Person("John", "Doe"), Person("Jane", "Doe"))
|
||||||
|
}
|
||||||
|
}
|
||||||
+2
-14
@@ -19,26 +19,14 @@ package com.bnorm.power
|
|||||||
import kotlin.test.Test
|
import kotlin.test.Test
|
||||||
import kotlin.test.assertTrue
|
import kotlin.test.assertTrue
|
||||||
|
|
||||||
data class Person(
|
|
||||||
val firstName: String,
|
|
||||||
val lastName: String
|
|
||||||
)
|
|
||||||
|
|
||||||
class PowerAssertTest {
|
class PowerAssertTest {
|
||||||
private val people = listOf(Person("John", "Doe"), Person("Jane", "Doe"))
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun assertTrue() {
|
fun assertTrue() {
|
||||||
assertTrue(people.size == 1)
|
assertTrue(Person.UNKNOWN.size == 1)
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
fun assert() {
|
|
||||||
assert(people.size == 1)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun require() {
|
fun require() {
|
||||||
require(people.size == 1)
|
require(Person.UNKNOWN.size == 1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2020 Brian Norman
|
||||||
|
*
|
||||||
|
* 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 com.bnorm.power
|
||||||
|
|
||||||
|
import kotlin.test.Test
|
||||||
|
|
||||||
|
class JvmPowerAssertTest {
|
||||||
|
@Test
|
||||||
|
fun assert() {
|
||||||
|
assert(Person.UNKNOWN.size == 1)
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user