|
11 | 11 | using UnityEngine; |
12 | 12 | using UnityEngine.TestTools; |
13 | 13 | using VRC.Udon; |
| 14 | +using VRC.Udon.Common.Interfaces; |
14 | 15 |
|
15 | 16 | public class MenSharpIntegrationTests |
16 | 17 | { |
@@ -679,5 +680,28 @@ public void NetworkCallableRatesComeFromConstantsAndAliases() |
679 | 680 | Assert.AreEqual(5, rates["Aim"]); |
680 | 681 | Assert.AreEqual(0, rates["Hit"]); |
681 | 682 | } |
| 683 | + |
| 684 | + /// The declared variable types the inspector asks for before every |
| 685 | + /// play-mode repaint come from one symbol table per build of the |
| 686 | + /// program, not from a fresh RetrieveProgram (a whole-heap |
| 687 | + /// deserialization) each time; a rebuild drops the cached table. |
| 688 | + [Test] |
| 689 | + public void DeclaredSymbolsAreReadOncePerBuild() |
| 690 | + { |
| 691 | + MenSharpCompiler.CompileAll(); |
| 692 | + AssetDatabase.Refresh(ImportAssetOptions.ForceSynchronousImport); |
| 693 | + MenSharpProgramAsset program = MenSharpSources.FindProgram("MenSharpRuntimeSmoke"); |
| 694 | + Assert.IsNotNull(program, "MenSharpRuntimeSmoke program asset"); |
| 695 | + IUdonSymbolTable first = program.DeclaredSymbols(); |
| 696 | + Assert.IsNotNull(first); |
| 697 | + Assert.AreEqual(typeof(int), first.GetSymbolType("indexOfObject")); |
| 698 | + Assert.IsFalse(first.HasAddressForSymbol("noSuchVariable")); |
| 699 | + Assert.AreSame(first, program.DeclaredSymbols(), "the table is kept between lookups"); |
| 700 | + program.RefreshProgram(); |
| 701 | + IUdonSymbolTable rebuilt = program.DeclaredSymbols(); |
| 702 | + Assert.IsNotNull(rebuilt); |
| 703 | + Assert.AreNotSame(first, rebuilt, "a rebuild reads the symbols afresh"); |
| 704 | + Assert.AreEqual(typeof(int), rebuilt.GetSymbolType("indexOfObject")); |
| 705 | + } |
682 | 706 | } |
683 | 707 | #endif |
0 commit comments