fix: fix tests

fix dependency bugs in tests
This commit is contained in:
Frank.R.Wu 2021-11-10 16:52:08 +08:00
parent 9039930340
commit 9244bd768c
4 changed files with 42 additions and 41 deletions

View File

@ -55,6 +55,7 @@ jar {
}
tasks.processResources.setDuplicatesStrategy(DuplicatesStrategy.INCLUDE)
tasks.processTestResources.setDuplicatesStrategy(DuplicatesStrategy.INCLUDE)
task copyLibs(type: Copy, dependsOn: ":common:jar") {
into "./build/output/libs/"

View File

@ -2,8 +2,8 @@ package org.bdware.sc.engine.test;
import com.google.gson.JsonElement;
import com.google.gson.JsonParser;
import org.bdware.sc.engine.MockUtil;
import org.bdware.sc.util.MockSchemaParser;
import org.bdware.mockjava.MockSchemaParser;
import org.bdware.mockjava.MockUtil;
public class MockUtilTest {
public static void main(String[] args) {

View File

@ -1,27 +1,27 @@
package org.bdware.sc.parser;
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.DiagnosticErrorListener;
import org.bdware.sc.ContractResult;
import org.bdware.sc.bean.ContractRequest;
import org.bdware.sc.compiler.YJSCompiler;
import org.bdware.sc.compiler.YJSErrorListener;
import org.bdware.sc.engine.DesktopEngine;
import org.bdware.sc.node.ContractNode;
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 {
@Test
public void YJSParserElseTest(){
public void elseTest() throws IOException {
InputStream resource = YJSParserTest.class.getClassLoader().getResourceAsStream("module1.yjs");
JavaScriptLexer lexer = null;
try {
lexer = new JavaScriptLexer(new ANTLRInputStream(resource));
JavaScriptLexer lexer;
assert resource != null;
lexer = new JavaScriptLexer(CharStreams.fromStream(resource));
lexer.setUseStrictDefault(true);
CommonTokenStream cts = new CommonTokenStream(lexer);
YJSErrorListener errorListener = new YJSErrorListener();
@ -31,45 +31,42 @@ public class YJSParserTest {
parser.addErrorListener(errorListener);
parser.addErrorListener(new DiagnosticErrorListener());
YJSParser.ProgramContext tree = parser.program();
for (String str:errorListener.getResultList())
for (String str : errorListener.getResultList())
System.out.println(str);
} catch (IOException e) {
e.printStackTrace();
}
}
@Test
public void functionTest(){
public void functionTest() throws IOException {
InputStream resource = YJSParserTest.class.getClassLoader().getResourceAsStream("function.yjs");
JavaScriptLexer lexer = null;
try {
lexer = new JavaScriptLexer(new ANTLRInputStream(resource));
lexer.setUseStrictDefault(true);
CommonTokenStream cts = new CommonTokenStream(lexer);
YJSErrorListener errorListener = new YJSErrorListener();
// 语法分析
YJSParser parser = new YJSParser(cts);
parser.removeErrorListeners();
parser.addErrorListener(errorListener);
parser.addErrorListener(new DiagnosticErrorListener());
YJSParser.ProgramContext tree = parser.program();
for (String str:errorListener.getResultList())
System.out.println(str);
} catch (IOException e) {
e.printStackTrace();
JavaScriptLexer lexer;
assert resource != null;
lexer = new JavaScriptLexer(CharStreams.fromStream(resource));
lexer.setUseStrictDefault(true);
CommonTokenStream cts = new CommonTokenStream(lexer);
YJSErrorListener errorListener = new YJSErrorListener();
// 语法分析
YJSParser parser = new YJSParser(cts);
parser.removeErrorListeners();
parser.addErrorListener(errorListener);
parser.addErrorListener(new DiagnosticErrorListener());
YJSParser.ProgramContext tree = parser.program();
for (YJSParser.ClzOrFunctionDeclarationContext clzOrFunc : tree.contractDeclar().clzOrFunctionDeclaration()) {
System.out.println(clzOrFunc.functionDeclaration().View());
}
for (String str : errorListener.getResultList()) {
System.out.println(str);
}
}
@Test
public void YJSParserTest() throws FileNotFoundException {//测试执行 engine executeContract方法
InputStream resource = new FileInputStream("../front-agent/BDWareProjectDir/public/ARouteExample/ARouteExample.yjs");
public void test() throws FileNotFoundException {//测试执行 engine executeContract方法
InputStream resource = new FileInputStream(
"../front-agent/BDWareProjectDir/public/ARouteExample/ARouteExample.yjs");
YJSCompiler compiler = new YJSCompiler();
try {
ContractNode cn = compiler.compile(resource, "rrr.yjs");
DesktopEngine engine = new DesktopEngine();
System.out.println(new Gson().toJson(cn));
new DesktopEngine();
System.out.println(new Gson().toJson(cn));
} catch (IOException e) {
e.printStackTrace();
}

View File

@ -1,5 +1,8 @@
contract str{
export funccion ab(){
contract str {
export function ab() {
return "world!";
}
function cd() view {
return "view!";
}
}