Skip to content
This repository has been archived by the owner on Apr 13, 2023. It is now read-only.

Support class members for test parameters resolution (enhancement) #635

Open
olegnekludov opened this issue Nov 5, 2016 · 1 comment
Open
Labels
Milestone

Comments

@olegnekludov
Copy link

In ceylon.test "1.3.0" if I use class attribute as parameters source there is exception (if I use value outside class - its ok): ceylon.language.meta.model.TypeApplicationException "Cannot apply a member declaration with no container type: use memberApply":

class NestedArrayTest() {
    shared {[ClassDeclaration, [String, String]]*} testJsonValuesParams => {
        [`class DummyArraySequential`, ["[", "]"]]
    };

    test
    parameters(`value testJsonValuesParams`)
    shared void testJsonValues(ClassDeclaration clsDecl, [String, String] brackets) {
...
======================== TESTS STARTED =======================
running: test.org.ceylonforge.jsonmapper::NestedArrayTest
ceylon.language.meta.model.TypeApplicationException "Cannot apply a member declaration with no container type: use memberApply"
	at com.redhat.ceylon.compiler.java.runtime.metamodel.decl.ValueDeclarationImpl.apply(ValueDeclarationImpl.java:105)
	at ceylon.test.annotation.ParametersAnnotation.arguments(annotations.ceylon:95)
	at ceylon.test.annotation.ParametersAnnotation.argumentLists(annotations.ceylon:100)
	at ceylon.test.engine.DefaultArgumentListResolver.resolve(DefaultArgumentListResolver.ceylon:38)
	at ceylon.test.engine.DefaultTestExecutor.execute(DefaultTestExecutor.ceylon:48)
	at ceylon.test.engine.internal.GroupTestExecutor$2$1$1.$call$(executors.ceylon:34)
	at ceylon.test.engine.spi.TaskExecutor.executionLoop(TestExecutionContext.ceylon:127)
	at ceylon.test.engine.spi.TaskExecutor.execute$canonical$(TestExecutionContext.ceylon:121)
	at ceylon.test.engine.spi.TaskExecutor.execute(TestExecutionContext.ceylon:110)
	at ceylon.test.engine.spi.TestExecutionContext.execute$canonical$(TestExecutionContext.ceylon:71)
	at ceylon.test.engine.spi.TestExecutionContext.execute(TestExecutionContext.ceylon:70)
	at ceylon.test.engine.DefaultTestRunner.runInternal$priv$(DefaultTestRunner.ceylon:94)
	at ceylon.test.engine.DefaultTestRunner.run(DefaultTestRunner.ceylon:58)
	at test.org.ceylonforge.jsonmapper.runOneTest_.runOneTest(NestedArrayTest.ceylon:29)
	at test.org.ceylonforge.jsonmapper.runOneTest_.main(NestedArrayTest.ceylon)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:497)
	at ceylon.modules.api.runtime.SecurityActions.invokeRunInternal(SecurityActions.java:57)
	at ceylon.modules.api.runtime.SecurityActions.invokeRun(SecurityActions.java:48)
	at ceylon.modules.api.runtime.AbstractRuntime.invokeRun(AbstractRuntime.java:68)
	at ceylon.modules.api.runtime.AbstractRuntime.execute(AbstractRuntime.java:105)
	at ceylon.modules.api.runtime.AbstractRuntime.execute(AbstractRuntime.java:101)
	at ceylon.modules.Main.execute(Main.java:69)
	at ceylon.modules.Main.main(Main.java:42)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:497)
	at org.jboss.modules.Module.run(Module.java:308)
	at org.jboss.modules.Main.main(Main.java:487)
	at ceylon.modules.bootstrap.CeylonRunTool.run(CeylonRunTool.java:307)
	at com.redhat.ceylon.common.tools.CeylonTool.run(CeylonTool.java:524)
	at com.redhat.ceylon.common.tools.CeylonTool.execute(CeylonTool.java:405)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:497)
	at com.redhat.ceylon.launcher.Launcher.runInJava7Checked(Launcher.java:115)
	at com.redhat.ceylon.launcher.Launcher.run(Launcher.java:41)
	at com.redhat.ceylon.launcher.Launcher.run(Launcher.java:34)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:497)
	at com.redhat.ceylon.launcher.Bootstrap.runInternal(Bootstrap.java:139)
	at com.redhat.ceylon.launcher.Bootstrap.run(Bootstrap.java:93)
	at com.redhat.ceylon.launcher.Bootstrap.main(Bootstrap.java:85)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:497)======================== TEST RESULTS ========================
run:     0
success: 0
failure: 0
error:   1
skipped: 0
aborted: 0
time:    0s

test.org.ceylonforge.jsonmapper::NestedArrayTest.testJsonValues - error (ceylon.language.meta.model.TypeApplicationException "Cannot apply a member declaration with no container type: use memberApply")

======================= TESTS FAILED ! =======================
@lucaswerkmeister
Copy link

Similarly, I find it very useful to compose test cases into bigger test cases, and to collect them in a toplevel object for this purpose:

alias Test => [String, Value];
object tests {
    shared Test test1 = ["foo", Str("foo")];
    shared Test test2 = ["bar", Str("bar")];
    shared Test test3 = [test1[0] + "," + test2[0], Comp(test1[1], test2[1])];
    
    shared Test[] allTests = [test1, test2, test3];
}

test
parameters (`value tests.allTests`)
shared void myTest(String text, Value expected)
        => assertEquals { expected = expected; actual = parse(text); };

But using tests.allTests for the parameters is currently not supported either. Fortunately, there’s a simple workaround:

shared Test[] allTests => tests.allTests;

parameters (`value allTests`)

@FroMage FroMage modified the milestones: 1.3.3, 1.4.0 beta Sep 6, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

5 participants