Convert orx-shader-phrases and orx-noise to MPP
This commit is contained in:
@@ -1,53 +0,0 @@
|
||||
import org.amshove.kluent.`should contain`
|
||||
import org.amshove.kluent.`should throw`
|
||||
import org.amshove.kluent.`with message`
|
||||
import org.amshove.kluent.invoking
|
||||
import org.openrndr.extra.shaderphrases.preprocessShader
|
||||
import org.openrndr.extra.shaderphrases.preprocessShaderFromUrl
|
||||
import org.openrndr.resourceUrl
|
||||
import org.spekframework.spek2.Spek
|
||||
import org.spekframework.spek2.style.specification.describe
|
||||
|
||||
object TestPreprocessShader : Spek({
|
||||
describe("An url pointing to a shader resource") {
|
||||
val url = resourceUrl("/from-url-test.frag")
|
||||
describe("results in injected dummy phrase when preprocessed") {
|
||||
val processed = preprocessShaderFromUrl(url)
|
||||
processed `should contain` "float dummy"
|
||||
}
|
||||
}
|
||||
|
||||
describe("A shader with import statements") {
|
||||
val shader = """
|
||||
|#version 330
|
||||
|#pragma import org.openrndr.extra.shaderphrases.phrases.Dummy.*""".trimMargin()
|
||||
describe("injects dummy phrase when preprocessed") {
|
||||
val processed = preprocessShader(shader)
|
||||
processed `should contain` "float dummy"
|
||||
}
|
||||
}
|
||||
|
||||
describe("A shader with non-resolvable class statements") {
|
||||
val shader = """#version 330
|
||||
#pragma import invalid.Class.*
|
||||
"""
|
||||
describe("throws exception when preprocessed") {
|
||||
invoking {
|
||||
preprocessShader(shader)
|
||||
} `should throw` RuntimeException::class `with message`
|
||||
("class \"invalid.Class\" not found in \"#pragma import invalid.Class\" on line 2")
|
||||
}
|
||||
}
|
||||
|
||||
describe("A shader with non-resolvable property statements") {
|
||||
val shader = """#version 330
|
||||
#pragma import org.openrndr.extra.shaderphrases.phrases.Dummy.invalid
|
||||
"""
|
||||
describe("throws exception when preprocessed") {
|
||||
invoking {
|
||||
preprocessShader(shader)
|
||||
} `should throw` RuntimeException::class `with message`
|
||||
("field \"invalid\" not found in \"#pragma import org.openrndr.extra.shaderphrases.phrases.Dummy.invalid\" on line 2")
|
||||
}
|
||||
}
|
||||
})
|
||||
@@ -1,20 +0,0 @@
|
||||
import org.amshove.kluent.`should be`
|
||||
import org.openrndr.extra.shaderphrases.ShaderPhrase
|
||||
import org.openrndr.extra.shaderphrases.ShaderPhraseRegistry
|
||||
import org.spekframework.spek2.Spek
|
||||
import org.spekframework.spek2.style.specification.describe
|
||||
|
||||
object TestShaderPhrase : Spek({
|
||||
describe("A shader phrase") {
|
||||
val phrase = ShaderPhrase("""
|
||||
|vec4 test_phrase() {
|
||||
|}
|
||||
""".trimMargin() )
|
||||
it("can be registered") {
|
||||
phrase.register()
|
||||
}
|
||||
it("can be found") {
|
||||
ShaderPhraseRegistry.findPhrase("test_phrase") `should be` phrase
|
||||
}
|
||||
}
|
||||
})
|
||||
@@ -1,23 +0,0 @@
|
||||
import org.amshove.kluent.`should be`
|
||||
import org.openrndr.extra.shaderphrases.ShaderPhrase
|
||||
import org.openrndr.extra.shaderphrases.ShaderPhraseBook
|
||||
import org.openrndr.extra.shaderphrases.ShaderPhraseRegistry
|
||||
import org.spekframework.spek2.Spek
|
||||
import org.spekframework.spek2.style.specification.describe
|
||||
|
||||
class TestShaderPhraseBookobject : Spek({
|
||||
describe("A shader phrase book") {
|
||||
val book = object:ShaderPhraseBook("testBook") {
|
||||
val phrase = ShaderPhrase("""
|
||||
|vec4 test_phrase() {
|
||||
|}
|
||||
""".trimMargin() )
|
||||
}
|
||||
it("can be registered") {
|
||||
book.register()
|
||||
}
|
||||
it("can be found") {
|
||||
ShaderPhraseRegistry.findPhrase("testBook.test_phrase") `should be` book.phrase
|
||||
}
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user