Skip to content

Commit

Permalink
[unity]补充这个场景的测试用例:#1670
Browse files Browse the repository at this point in the history
  • Loading branch information
chexiongsheng committed Mar 27, 2024
1 parent 77aeeb5 commit c95456f
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions unity/test/Src/Cases/API/EvalTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,58 @@ public void ESModuleCompileError()
throw new Exception("unexpected to reach here");
}
#endif
[Test]
public void ESModuleCompileErrorInNested() //https://github.com/Tencent/puerts/issues/1670
{
var loader = UnitTestEnv.GetLoader();
loader.AddMockFileContent("compile-error/AModule.mjs", @"import BModule from ""./BModule.mjs""
class AModule
{
}
console.log(`===AModule=====`);
export default AModule;");
loader.AddMockFileContent("compile-error/BModule.mjs", @"import CrashTest from ""CrashTest.mjs""
class BModule
{
}
console.log(`===BModule=====`);
export default BModule;");
loader.AddMockFileContent("compile-error/CrashTest.mjs", @"
class CrashTest
{
async doSomthine(content) {
let content = '123'; //这里声明的变量,和输入参数一样,语法错误导致,启动后Unity崩溃。
return content;
}
}
console.log(`======CrashTest======`)
export default CrashTest;");
var jsEnv = UnitTestEnv.GetEnv();
for (int i = 0; i < 10; ++i)
{
try
{
jsEnv.ExecuteModule("compile-error/AModule.mjs");
}
catch(Exception e)
{
continue;
}
throw new Exception("unexpected to reach here");
}
}

[Test]
public void ESModuleEvaluateError()
{
Expand Down

0 comments on commit c95456f

Please sign in to comment.