mirror of
https://gitee.com/BDWare/cp.git
synced 2025-01-10 01:44:08 +00:00
fix: fix tests
fix dependency bugs in tests
This commit is contained in:
parent
9039930340
commit
9244bd768c
@ -55,6 +55,7 @@ jar {
|
|||||||
}
|
}
|
||||||
|
|
||||||
tasks.processResources.setDuplicatesStrategy(DuplicatesStrategy.INCLUDE)
|
tasks.processResources.setDuplicatesStrategy(DuplicatesStrategy.INCLUDE)
|
||||||
|
tasks.processTestResources.setDuplicatesStrategy(DuplicatesStrategy.INCLUDE)
|
||||||
|
|
||||||
task copyLibs(type: Copy, dependsOn: ":common:jar") {
|
task copyLibs(type: Copy, dependsOn: ":common:jar") {
|
||||||
into "./build/output/libs/"
|
into "./build/output/libs/"
|
||||||
|
@ -2,8 +2,8 @@ package org.bdware.sc.engine.test;
|
|||||||
|
|
||||||
import com.google.gson.JsonElement;
|
import com.google.gson.JsonElement;
|
||||||
import com.google.gson.JsonParser;
|
import com.google.gson.JsonParser;
|
||||||
import org.bdware.sc.engine.MockUtil;
|
import org.bdware.mockjava.MockSchemaParser;
|
||||||
import org.bdware.sc.util.MockSchemaParser;
|
import org.bdware.mockjava.MockUtil;
|
||||||
|
|
||||||
public class MockUtilTest {
|
public class MockUtilTest {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
@ -1,27 +1,27 @@
|
|||||||
package org.bdware.sc.parser;
|
package org.bdware.sc.parser;
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import org.antlr.v4.runtime.ANTLRInputStream;
|
import org.antlr.v4.runtime.CharStreams;
|
||||||
import org.antlr.v4.runtime.CommonTokenStream;
|
import org.antlr.v4.runtime.CommonTokenStream;
|
||||||
import org.antlr.v4.runtime.DiagnosticErrorListener;
|
import org.antlr.v4.runtime.DiagnosticErrorListener;
|
||||||
import org.bdware.sc.ContractResult;
|
|
||||||
import org.bdware.sc.bean.ContractRequest;
|
|
||||||
import org.bdware.sc.compiler.YJSCompiler;
|
import org.bdware.sc.compiler.YJSCompiler;
|
||||||
import org.bdware.sc.compiler.YJSErrorListener;
|
import org.bdware.sc.compiler.YJSErrorListener;
|
||||||
import org.bdware.sc.engine.DesktopEngine;
|
import org.bdware.sc.engine.DesktopEngine;
|
||||||
import org.bdware.sc.node.ContractNode;
|
import org.bdware.sc.node.ContractNode;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.FileInputStream;
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
|
||||||
public class YJSParserTest {
|
public class YJSParserTest {
|
||||||
@Test
|
@Test
|
||||||
public void YJSParserElseTest(){
|
public void elseTest() throws IOException {
|
||||||
InputStream resource = YJSParserTest.class.getClassLoader().getResourceAsStream("module1.yjs");
|
InputStream resource = YJSParserTest.class.getClassLoader().getResourceAsStream("module1.yjs");
|
||||||
JavaScriptLexer lexer = null;
|
JavaScriptLexer lexer;
|
||||||
try {
|
assert resource != null;
|
||||||
lexer = new JavaScriptLexer(new ANTLRInputStream(resource));
|
lexer = new JavaScriptLexer(CharStreams.fromStream(resource));
|
||||||
|
|
||||||
lexer.setUseStrictDefault(true);
|
lexer.setUseStrictDefault(true);
|
||||||
CommonTokenStream cts = new CommonTokenStream(lexer);
|
CommonTokenStream cts = new CommonTokenStream(lexer);
|
||||||
YJSErrorListener errorListener = new YJSErrorListener();
|
YJSErrorListener errorListener = new YJSErrorListener();
|
||||||
@ -31,45 +31,42 @@ public class YJSParserTest {
|
|||||||
parser.addErrorListener(errorListener);
|
parser.addErrorListener(errorListener);
|
||||||
parser.addErrorListener(new DiagnosticErrorListener());
|
parser.addErrorListener(new DiagnosticErrorListener());
|
||||||
YJSParser.ProgramContext tree = parser.program();
|
YJSParser.ProgramContext tree = parser.program();
|
||||||
for (String str:errorListener.getResultList())
|
for (String str : errorListener.getResultList())
|
||||||
System.out.println(str);
|
System.out.println(str);
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void functionTest(){
|
public void functionTest() throws IOException {
|
||||||
InputStream resource = YJSParserTest.class.getClassLoader().getResourceAsStream("function.yjs");
|
InputStream resource = YJSParserTest.class.getClassLoader().getResourceAsStream("function.yjs");
|
||||||
JavaScriptLexer lexer = null;
|
JavaScriptLexer lexer;
|
||||||
try {
|
assert resource != null;
|
||||||
lexer = new JavaScriptLexer(new ANTLRInputStream(resource));
|
lexer = new JavaScriptLexer(CharStreams.fromStream(resource));
|
||||||
|
lexer.setUseStrictDefault(true);
|
||||||
lexer.setUseStrictDefault(true);
|
CommonTokenStream cts = new CommonTokenStream(lexer);
|
||||||
CommonTokenStream cts = new CommonTokenStream(lexer);
|
YJSErrorListener errorListener = new YJSErrorListener();
|
||||||
YJSErrorListener errorListener = new YJSErrorListener();
|
// 语法分析
|
||||||
// 语法分析
|
YJSParser parser = new YJSParser(cts);
|
||||||
YJSParser parser = new YJSParser(cts);
|
parser.removeErrorListeners();
|
||||||
parser.removeErrorListeners();
|
parser.addErrorListener(errorListener);
|
||||||
parser.addErrorListener(errorListener);
|
parser.addErrorListener(new DiagnosticErrorListener());
|
||||||
parser.addErrorListener(new DiagnosticErrorListener());
|
YJSParser.ProgramContext tree = parser.program();
|
||||||
YJSParser.ProgramContext tree = parser.program();
|
for (YJSParser.ClzOrFunctionDeclarationContext clzOrFunc : tree.contractDeclar().clzOrFunctionDeclaration()) {
|
||||||
for (String str:errorListener.getResultList())
|
System.out.println(clzOrFunc.functionDeclaration().View());
|
||||||
System.out.println(str);
|
}
|
||||||
} catch (IOException e) {
|
for (String str : errorListener.getResultList()) {
|
||||||
e.printStackTrace();
|
System.out.println(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void YJSParserTest() throws FileNotFoundException {//测试执行 engine 的 executeContract方法
|
public void test() throws FileNotFoundException {//测试执行 engine 的 executeContract方法
|
||||||
InputStream resource = new FileInputStream("../front-agent/BDWareProjectDir/public/ARouteExample/ARouteExample.yjs");
|
InputStream resource = new FileInputStream(
|
||||||
|
"../front-agent/BDWareProjectDir/public/ARouteExample/ARouteExample.yjs");
|
||||||
YJSCompiler compiler = new YJSCompiler();
|
YJSCompiler compiler = new YJSCompiler();
|
||||||
try {
|
try {
|
||||||
ContractNode cn = compiler.compile(resource, "rrr.yjs");
|
ContractNode cn = compiler.compile(resource, "rrr.yjs");
|
||||||
DesktopEngine engine = new DesktopEngine();
|
new DesktopEngine();
|
||||||
System.out.println(new Gson().toJson(cn));
|
System.out.println(new Gson().toJson(cn));
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
contract str{
|
contract str {
|
||||||
export funccion ab(){
|
export function ab() {
|
||||||
|
return "world!";
|
||||||
|
}
|
||||||
|
function cd() view {
|
||||||
|
return "view!";
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user