Skip to content

Commit ad9001d

Browse files
committed
feat(tests): add parsing tests for DevIn language
1 parent cfe4699 commit ad9001d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+3728
-2
lines changed

exts/devins-lang/src/test/kotlin/cc/unitmesh/devti/language/DevInParsingTest.kt renamed to exts/devins-lang/src/test/kotlin/cc/unitmesh/devti/language/parse/DevInParsingTest.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package cc.unitmesh.devti.language
1+
package cc.unitmesh.devti.language.parse
22

33
import cc.unitmesh.devti.language.parser.DevInParserDefinition
44
import com.intellij.testFramework.ParsingTestCase
@@ -47,4 +47,4 @@ class DevInParsingTest : ParsingTestCase("parser", "devin", DevInParserDefinitio
4747
fun testAutoRefactor() {
4848
doTest(true)
4949
}
50-
}
50+
}
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
package cc.unitmesh.devti.language.parse
2+
3+
import cc.unitmesh.devti.language.parser.DevInParserDefinition
4+
import com.intellij.testFramework.ParsingTestCase
5+
6+
class ParsingNormalTest : ParsingTestCase("normal", "devin", DevInParserDefinition()) {
7+
override fun getTestDataPath(): String {
8+
return "src/test/testData"
9+
}
10+
11+
fun testBasicTest() {
12+
doTest(true)
13+
}
14+
15+
fun testJavaHelloWorld() {
16+
doTest(true)
17+
}
18+
19+
fun testEmptyCodeFence() {
20+
doTest(true)
21+
}
22+
23+
fun testJavaAnnotation() {
24+
doTest(true)
25+
}
26+
27+
fun testBlockStartOnly() {
28+
doTest(true)
29+
}
30+
31+
fun testComplexLangId() {
32+
doTest(true)
33+
}
34+
35+
fun testAutoCommand() {
36+
doTest(true)
37+
}
38+
39+
fun testCommandAndSymbol() {
40+
doTest(true)
41+
}
42+
43+
fun testBrowseWeb() {
44+
doTest(true)
45+
}
46+
47+
fun testAutoRefactor() {
48+
doTest(true)
49+
}
50+
51+
fun testFrontMatter() {
52+
doTest(true)
53+
}
54+
55+
fun testSingleComment() {
56+
doTest(true)
57+
}
58+
59+
fun testShireFmObject() {
60+
doTest(true)
61+
}
62+
63+
fun testPatternAction() {
64+
doTest(true)
65+
}
66+
67+
fun testPatternCaseAction() {
68+
doTest(true)
69+
}
70+
71+
fun testWhenCondition() {
72+
doTest(true)
73+
}
74+
75+
fun testVariableAccess() {
76+
doTest(true)
77+
}
78+
79+
fun testShirePsiQueryExpression() {
80+
doTest(true)
81+
}
82+
83+
fun testMultipleFMVariable() {
84+
doTest(true)
85+
}
86+
87+
fun testAfterStream() {
88+
doTest(true)
89+
}
90+
91+
fun testMarkdownCompatible() {
92+
doTest(true)
93+
}
94+
95+
fun testCustomFunctions() {
96+
doTest(true)
97+
}
98+
99+
fun testIfExpression() {
100+
doTest(true)
101+
}
102+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
package cc.unitmesh.devti.language.parse
2+
3+
import cc.unitmesh.devti.language.parser.DevInParserDefinition
4+
import com.intellij.testFramework.ParsingTestCase
5+
6+
class ParsingRealWorldTest : ParsingTestCase("realworld", "devin", DevInParserDefinition()) {
7+
override fun getTestDataPath(): String {
8+
return "src/test/testData"
9+
}
10+
11+
fun testAutotest() {
12+
doTest(true)
13+
}
14+
15+
fun testLifeCycle() {
16+
doTest(true)
17+
}
18+
19+
fun testContentTee() {
20+
doTest(true)
21+
}
22+
23+
fun testWhenAfterStreaming() {
24+
doTest(true)
25+
}
26+
27+
fun testAfterStreamingOnly() {
28+
doTest(true)
29+
}
30+
31+
fun testOutputInVariable() {
32+
doTest(true)
33+
}
34+
35+
fun testOnPaste() {
36+
doTest(true)
37+
}
38+
39+
fun testLoginCommit() {
40+
doTest(true)
41+
}
42+
}
43+
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
afterStreaming: {
3+
condition {
4+
"variable-success" { $selection.length > 1 }
5+
"jsonpath-success" { jsonpath("/bookstore/book[price>35]") }
6+
}
7+
case condition {
8+
"variable-sucesss" { done }
9+
"jsonpath-success" { task() }
10+
default { task() }
11+
}
12+
}
13+
---
Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
DevInFile
2+
DevInFrontMatterHeaderImpl(FRONT_MATTER_HEADER)
3+
PsiElement(DevInTokenType.FRONTMATTER_START)('---')
4+
PsiElement(DevInTokenType.NEWLINE)('\n')
5+
DevInFrontMatterEntriesImpl(FRONT_MATTER_ENTRIES)
6+
DevInFrontMatterEntryImpl(FRONT_MATTER_ENTRY)
7+
DevInLifecycleIdImpl(LIFECYCLE_ID)
8+
PsiElement(DevInTokenType.afterStreaming)('afterStreaming')
9+
PsiElement(DevInTokenType.COLON)(':')
10+
PsiWhiteSpace(' ')
11+
DevInFunctionStatementImpl(FUNCTION_STATEMENT)
12+
PsiElement(DevInTokenType.{)('{')
13+
PsiElement(DevInTokenType.NEWLINE)('\n')
14+
PsiWhiteSpace(' ')
15+
DevInFunctionBodyImpl(FUNCTION_BODY)
16+
DevInActionBodyImpl(ACTION_BODY)
17+
DevInActionExprImpl(ACTION_EXPR)
18+
DevInCaseBodyImpl(CASE_BODY)
19+
DevInConditionFlagImpl(CONDITION_FLAG)
20+
PsiElement(DevInTokenType.condition)('condition')
21+
PsiWhiteSpace(' ')
22+
PsiElement(DevInTokenType.{)('{')
23+
PsiElement(DevInTokenType.NEWLINE)('\n')
24+
PsiWhiteSpace(' ')
25+
DevInConditionStatementImpl(CONDITION_STATEMENT)
26+
DevInCaseConditionImpl(CASE_CONDITION)
27+
PsiElement(DevInTokenType.QUOTE_STRING)('"variable-success"')
28+
PsiWhiteSpace(' ')
29+
PsiElement(DevInTokenType.{)('{')
30+
PsiWhiteSpace(' ')
31+
DevInIneqComparisonExprImpl(INEQ_COMPARISON_EXPR)
32+
DevInRefExprImpl(REF_EXPR)
33+
DevInLiteralExprImpl(LITERAL_EXPR)
34+
PsiElement(VARIABLE_START)('$')
35+
PsiElement(DevInTokenType.IDENTIFIER)('selection')
36+
PsiElement(DevInTokenType..)('.')
37+
PsiElement(DevInTokenType.IDENTIFIER)('length')
38+
PsiWhiteSpace(' ')
39+
DevInIneqComparisonOpImpl(INEQ_COMPARISON_OP)
40+
PsiElement(DevInTokenType.>)('>')
41+
PsiWhiteSpace(' ')
42+
DevInLiteralExprImpl(LITERAL_EXPR)
43+
PsiElement(DevInTokenType.NUMBER)('1')
44+
PsiWhiteSpace(' ')
45+
PsiElement(DevInTokenType.})('}')
46+
PsiElement(DevInTokenType.NEWLINE)('\n')
47+
PsiWhiteSpace(' ')
48+
DevInConditionStatementImpl(CONDITION_STATEMENT)
49+
DevInCaseConditionImpl(CASE_CONDITION)
50+
PsiElement(DevInTokenType.QUOTE_STRING)('"jsonpath-success"')
51+
PsiWhiteSpace(' ')
52+
PsiElement(DevInTokenType.{)('{')
53+
PsiWhiteSpace(' ')
54+
DevInCallExprImpl(CALL_EXPR)
55+
DevInRefExprImpl(REF_EXPR)
56+
PsiElement(DevInTokenType.IDENTIFIER)('jsonpath')
57+
PsiElement(DevInTokenType.()('(')
58+
DevInExpressionListImpl(EXPRESSION_LIST)
59+
DevInLiteralExprImpl(LITERAL_EXPR)
60+
PsiElement(DevInTokenType.QUOTE_STRING)('"/bookstore/book[price>35]"')
61+
PsiElement(DevInTokenType.))(')')
62+
PsiWhiteSpace(' ')
63+
PsiElement(DevInTokenType.})('}')
64+
PsiElement(DevInTokenType.NEWLINE)('\n')
65+
PsiWhiteSpace(' ')
66+
PsiElement(DevInTokenType.})('}')
67+
PsiElement(DevInTokenType.NEWLINE)('\n')
68+
PsiWhiteSpace(' ')
69+
PsiElement(DevInTokenType.case)('case')
70+
PsiWhiteSpace(' ')
71+
PsiElement(DevInTokenType.condition)('condition')
72+
PsiWhiteSpace(' ')
73+
PsiElement(DevInTokenType.{)('{')
74+
PsiElement(DevInTokenType.NEWLINE)('\n')
75+
PsiWhiteSpace(' ')
76+
DevInCasePatternActionImpl(CASE_PATTERN_ACTION)
77+
DevInCaseConditionImpl(CASE_CONDITION)
78+
PsiElement(DevInTokenType.QUOTE_STRING)('"variable-sucesss"')
79+
PsiWhiteSpace(' ')
80+
PsiElement(DevInTokenType.{)('{')
81+
PsiWhiteSpace(' ')
82+
DevInActionBodyImpl(ACTION_BODY)
83+
DevInActionExprImpl(ACTION_EXPR)
84+
DevInFuncCallImpl(FUNC_CALL)
85+
DevInFuncNameImpl(FUNC_NAME)
86+
PsiElement(DevInTokenType.IDENTIFIER)('done')
87+
PsiWhiteSpace(' ')
88+
PsiElement(DevInTokenType.})('}')
89+
PsiElement(DevInTokenType.NEWLINE)('\n')
90+
PsiWhiteSpace(' ')
91+
DevInCasePatternActionImpl(CASE_PATTERN_ACTION)
92+
DevInCaseConditionImpl(CASE_CONDITION)
93+
PsiElement(DevInTokenType.QUOTE_STRING)('"jsonpath-success"')
94+
PsiWhiteSpace(' ')
95+
PsiElement(DevInTokenType.{)('{')
96+
PsiWhiteSpace(' ')
97+
DevInActionBodyImpl(ACTION_BODY)
98+
DevInActionExprImpl(ACTION_EXPR)
99+
DevInFuncCallImpl(FUNC_CALL)
100+
DevInFuncNameImpl(FUNC_NAME)
101+
PsiElement(DevInTokenType.IDENTIFIER)('task')
102+
PsiElement(DevInTokenType.()('(')
103+
DevInPipelineArgsImpl(PIPELINE_ARGS)
104+
<empty list>
105+
PsiElement(DevInTokenType.))(')')
106+
PsiWhiteSpace(' ')
107+
PsiElement(DevInTokenType.})('}')
108+
PsiElement(DevInTokenType.NEWLINE)('\n')
109+
PsiWhiteSpace(' ')
110+
DevInCasePatternActionImpl(CASE_PATTERN_ACTION)
111+
DevInCaseConditionImpl(CASE_CONDITION)
112+
PsiElement(DevInTokenType.default)('default')
113+
PsiWhiteSpace(' ')
114+
PsiElement(DevInTokenType.{)('{')
115+
PsiWhiteSpace(' ')
116+
DevInActionBodyImpl(ACTION_BODY)
117+
DevInActionExprImpl(ACTION_EXPR)
118+
DevInFuncCallImpl(FUNC_CALL)
119+
DevInFuncNameImpl(FUNC_NAME)
120+
PsiElement(DevInTokenType.IDENTIFIER)('task')
121+
PsiElement(DevInTokenType.()('(')
122+
DevInPipelineArgsImpl(PIPELINE_ARGS)
123+
<empty list>
124+
PsiElement(DevInTokenType.))(')')
125+
PsiWhiteSpace(' ')
126+
PsiElement(DevInTokenType.})('}')
127+
PsiElement(DevInTokenType.NEWLINE)('\n')
128+
PsiWhiteSpace(' ')
129+
PsiElement(DevInTokenType.})('}')
130+
PsiElement(DevInTokenType.NEWLINE)('\n')
131+
PsiWhiteSpace(' ')
132+
PsiElement(DevInTokenType.})('}')
133+
PsiElement(DevInTokenType.NEWLINE)('\n')
134+
PsiElement(DevInTokenType.FRONTMATTER_END)('---')
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/write:Sample.file#L1-L12
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
DevInFile
2+
DevInUsedImpl(USED)
3+
DevInCommandStartImpl(COMMAND_START)
4+
PsiElement(COMMAND_START)('/')
5+
DevInCommandIdImpl(COMMAND_ID)
6+
PsiElement(DevInTokenType.IDENTIFIER)('write')
7+
PsiElement(DevInTokenType.COLON)(':')
8+
PsiElement(DevInTokenType.COMMAND_PROP)('Sample.file')
9+
PsiElement(DevInTokenType.#)('#')
10+
PsiElement(DevInTokenType.LINE_INFO)('L1-L12')
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/refactor:rename com.phodal.shirelang.run.ShireProgramRunner to com.phodal.shirelang.run.ShireProgramRunnerImpl
2+
/refactor:safeDelete com.phodal.shirelang.run.ShireProgramRunnerImpl
3+
/refactor:delete com.phodal.shirelang.run.ShireProgramRunnerImpl
4+
/refactor:move com.phodal.shirelang.ShireProgramRunner to com.phodal.shirelang.run.ShireProgramRunner
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
DevInFile
2+
DevInUsedImpl(USED)
3+
DevInCommandStartImpl(COMMAND_START)
4+
PsiElement(COMMAND_START)('/')
5+
DevInCommandIdImpl(COMMAND_ID)
6+
PsiElement(DevInTokenType.IDENTIFIER)('refactor')
7+
PsiElement(DevInTokenType.COLON)(':')
8+
PsiElement(DevInTokenType.COMMAND_PROP)('rename')
9+
PsiElement(DevInTokenType.TEXT_SEGMENT)(' com.phodal.shirelang.run.ShireProgramRunner to com.phodal.shirelang.run.ShireProgramRunnerImpl')
10+
PsiElement(DevInTokenType.NEWLINE)('\n')
11+
DevInUsedImpl(USED)
12+
DevInCommandStartImpl(COMMAND_START)
13+
PsiElement(COMMAND_START)('/')
14+
DevInCommandIdImpl(COMMAND_ID)
15+
PsiElement(DevInTokenType.IDENTIFIER)('refactor')
16+
PsiElement(DevInTokenType.COLON)(':')
17+
PsiElement(DevInTokenType.COMMAND_PROP)('safeDelete')
18+
PsiElement(DevInTokenType.TEXT_SEGMENT)(' com.phodal.shirelang.run.ShireProgramRunnerImpl')
19+
PsiElement(DevInTokenType.NEWLINE)('\n')
20+
DevInUsedImpl(USED)
21+
DevInCommandStartImpl(COMMAND_START)
22+
PsiElement(COMMAND_START)('/')
23+
DevInCommandIdImpl(COMMAND_ID)
24+
PsiElement(DevInTokenType.IDENTIFIER)('refactor')
25+
PsiElement(DevInTokenType.COLON)(':')
26+
PsiElement(DevInTokenType.COMMAND_PROP)('delete')
27+
PsiElement(DevInTokenType.TEXT_SEGMENT)(' com.phodal.shirelang.run.ShireProgramRunnerImpl')
28+
PsiElement(DevInTokenType.NEWLINE)('\n')
29+
DevInUsedImpl(USED)
30+
DevInCommandStartImpl(COMMAND_START)
31+
PsiElement(COMMAND_START)('/')
32+
DevInCommandIdImpl(COMMAND_ID)
33+
PsiElement(DevInTokenType.IDENTIFIER)('refactor')
34+
PsiElement(DevInTokenType.COLON)(':')
35+
PsiElement(DevInTokenType.COMMAND_PROP)('move')
36+
PsiElement(DevInTokenType.TEXT_SEGMENT)(' com.phodal.shirelang.ShireProgramRunner to com.phodal.shirelang.run.ShireProgramRunner')
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
你好 @hello-world sm
2+
解释一下代码
3+
$selection 表示选择的内容
4+
@agent-name 调用特定的 agent
5+
/file:Sample.file 从文件中读取内容
6+
/rev:632372da 从版本库中读取内容

0 commit comments

Comments
 (0)