Skip to content

Commit

Permalink
[unity]上一个提交的测试用例
Browse files Browse the repository at this point in the history
  • Loading branch information
chexiongsheng committed Sep 13, 2024
1 parent 2fd96d4 commit 7834901
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 1 deletion.
21 changes: 20 additions & 1 deletion unity/test/Src/Cases/LazyWeakCJSTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public void HalfRefAutoReleaseTest()
[Test]
public void ManualReleaseTest()
{
#if PUERTS_GENERAL
#if PUERTS_GENERAL
var jsEnv = new JsEnv(new TxtLoader());
#else
var jsEnv = new JsEnv(new DefaultLoader());
Expand All @@ -138,6 +138,25 @@ public void ManualReleaseTest()

Assert.AreEqual(false, jsEnv.Eval<bool>("puer.module.hasModuleCache('lazymodule.cjs')"));
}

[Test]
public void CircularReqireTest()
{
#if PUERTS_GENERAL
var jsEnv = new JsEnv(new TxtLoader());
#else
var jsEnv = new JsEnv(new DefaultLoader());
#endif
jsEnv.ExecuteModule("puerts/module.mjs");

var res = jsEnv.Eval<string>(@"
const require = puer.module.createRequire('');
var lm = require('circular_m1.cjs');
lm.foo();
");

Assert.AreEqual("hello john", res);
}
}
}
//#endif
11 changes: 11 additions & 0 deletions unity/test/Src/Resources/circular_m1.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const m2 = require('circular_m2.cjs');

exports.foo = () => {
return m2.bar(); // expect "hello john"
}

exports.f1 = "hello john";


m2.bar();

5 changes: 5 additions & 0 deletions unity/test/Src/Resources/circular_m2.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const m1 = require('circular_m1.cjs');

exports.bar = () => {
return m1.f1;
}

0 comments on commit 7834901

Please sign in to comment.