-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8d2bd9c
commit 7d53687
Showing
12 changed files
with
164 additions
and
6 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 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 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
33 changes: 33 additions & 0 deletions
33
nop-xlang/src/test/java/io/nop/xlang/xdsl/TestMacroGen.java
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,33 @@ | ||
package io.nop.xlang.xdsl; | ||
|
||
import io.nop.core.initialize.CoreInitialization; | ||
import io.nop.core.lang.xml.IXNodeGenerator; | ||
import io.nop.core.lang.xml.XNode; | ||
import io.nop.core.model.object.DynamicObject; | ||
import io.nop.core.unittest.BaseTestCase; | ||
import io.nop.xlang.api.XLang; | ||
import org.junit.jupiter.api.AfterAll; | ||
import org.junit.jupiter.api.BeforeAll; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
public class TestMacroGen extends BaseTestCase { | ||
@BeforeAll | ||
public static void init() { | ||
CoreInitialization.initialize(); | ||
} | ||
|
||
@AfterAll | ||
public static void destroy() { | ||
CoreInitialization.destroy(); | ||
} | ||
|
||
@Test | ||
public void testGenExtends() { | ||
DynamicObject obj = (DynamicObject) new DslModelParser().parseFromVirtualPath("/test/macro/test-macro-gen.xml"); | ||
IXNodeGenerator generator = (IXNodeGenerator) obj.prop_get("filter"); | ||
XNode node = generator.generateNode(XLang.newEvalScope()); | ||
assertEquals(1, node.child(0).attrInt("value")); | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
nop-xlang/src/test/resources/_vfs/test/macro/test-macro-gen.xdef
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,6 @@ | ||
<model x:schema="/nop/schema/xdef.xdef" xmlns:xdef="/nop/schema/xdef.xdef" | ||
xmlns:x="/nop/schema/xdsl.xdef"> | ||
|
||
<filter xdef:value="xpl-node"/> | ||
|
||
</model> |
26 changes: 26 additions & 0 deletions
26
nop-xlang/src/test/resources/_vfs/test/macro/test-macro-gen.xml
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 @@ | ||
<model x:schema="/test/macro/test-macro-gen.xdef" xmlns:x="/nop/schema/xdsl.xdef" xmlns:batch="batch"> | ||
<x:pre-parse> | ||
<c:script> | ||
const task = _dsl_root.childByTag('batch:task'); | ||
_dsl_root.removeChild(task); | ||
|
||
const count = task.childByTag('steps').getChildCount(); | ||
|
||
assign('metaChildCount', count); | ||
</c:script> | ||
</x:pre-parse> | ||
|
||
<batch:task> | ||
<steps> | ||
<xpl id="step1"> | ||
<source> | ||
<c:log info="ss"/> | ||
</source> | ||
</xpl> | ||
</steps> | ||
</batch:task> | ||
|
||
<filter> | ||
<eq name="count" value="#{metaChildCount}" /> | ||
</filter> | ||
</model> |