-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add unit tests and update build script.
- Loading branch information
Showing
18 changed files
with
327 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
src/test/kotlin/net/fabricmc/language/kotlin/test/KotlinAdapterTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
/* | ||
* Copyright 2016 FabricMC | ||
* | ||
* 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 net.fabricmc.language.kotlin.test | ||
|
||
import net.fabricmc.api.ModInitializer | ||
import net.fabricmc.language.kotlin.KotlinAdapter | ||
import net.fabricmc.loader.api.FabricLoader | ||
import kotlin.test.Test | ||
|
||
class KotlinAdapterTest { | ||
@Test | ||
fun classEntrypoint() { | ||
testEntrypoint("net.fabricmc.language.kotlin.test.entrypoints.ClassEntrypoint") | ||
} | ||
|
||
@Test | ||
fun objectClassEntrypoint() { | ||
testEntrypoint("net.fabricmc.language.kotlin.test.entrypoints.ObjectClassEntrypoint") | ||
} | ||
|
||
@Test | ||
fun objectFunctionEntrypoint() { | ||
testEntrypoint("net.fabricmc.language.kotlin.test.entrypoints.ObjectFunctionEntrypoint::init") | ||
} | ||
|
||
@Test | ||
fun objectFieldEntrypoint() { | ||
testEntrypoint("net.fabricmc.language.kotlin.test.entrypoints.ObjectFieldEntrypoint::initializer") | ||
} | ||
|
||
@Test | ||
fun companionClassEntrypoint() { | ||
testEntrypoint("net.fabricmc.language.kotlin.test.entrypoints.CompanionClassEntrypoint\$Companion") | ||
} | ||
|
||
@Test | ||
fun companionFunctionEntrypoint() { | ||
testEntrypoint("net.fabricmc.language.kotlin.test.entrypoints.CompanionFunctionEntrypoint\$Companion::init") | ||
} | ||
|
||
@Test | ||
fun companionFieldEntrypoint() { | ||
testEntrypoint("net.fabricmc.language.kotlin.test.entrypoints.CompanionFieldEntrypoint\$Companion::initializer") | ||
} | ||
|
||
@Test | ||
fun topLevelEntrypoint() { | ||
testEntrypoint("net.fabricmc.language.kotlin.test.entrypoints.TopLevelEntrypointKt::init") | ||
} | ||
|
||
private fun testEntrypoint(value: String) { | ||
FabricLoader.getInstance().objectShare.remove("fabric-language-kotlin:test") | ||
|
||
val modContainer = FabricLoader.getInstance().getModContainer("fabric-language-kotlin").get() | ||
val entrypoint = KotlinAdapter().create(modContainer, value, ModInitializer::class.java) | ||
entrypoint.onInitialize() | ||
|
||
assert(FabricLoader.getInstance().objectShare.get("fabric-language-kotlin:test") == "true") | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
src/test/kotlin/net/fabricmc/language/kotlin/test/entrypoints/ClassEntrypoint.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* | ||
* Copyright 2016 FabricMC | ||
* | ||
* 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 net.fabricmc.language.kotlin.test.entrypoints | ||
|
||
import net.fabricmc.api.ModInitializer | ||
import net.fabricmc.loader.api.FabricLoader | ||
|
||
class ClassEntrypoint : ModInitializer { | ||
override fun onInitialize() { | ||
FabricLoader.getInstance().objectShare.put("fabric-language-kotlin:test", "true") | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
src/test/kotlin/net/fabricmc/language/kotlin/test/entrypoints/CompanionClassEntrypoint.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* | ||
* Copyright 2016 FabricMC | ||
* | ||
* 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 net.fabricmc.language.kotlin.test.entrypoints | ||
|
||
import net.fabricmc.api.ModInitializer | ||
import net.fabricmc.loader.api.FabricLoader | ||
|
||
class CompanionClassEntrypoint { | ||
companion object: ModInitializer { | ||
override fun onInitialize() { | ||
FabricLoader.getInstance().objectShare.put("fabric-language-kotlin:test", "true") | ||
} | ||
} | ||
} |
Oops, something went wrong.