• source navigation  • diff markup  • identifier search  • freetext search  • 

Sources/ucode/tests/custom/04_modules/16_multi_program_imports

  1 This testcase asserts that import/export symbols in runtime loaded code
  2 are properly dealt with.
  3 
  4 Since the compiler has no knowledge about runtime loaded code it cannot
  5 reserve slots in the export table, requiring the VM to maintain one export
  6 table per program instance.
  7 
  8 The dependency tree is:
  9 
 10 root
 11  + import: mod1
 12  + import: mod2
 13  + require: mod3
 14     + import: mod1
 15     + import: mod2
 16 
 17 -- Testcase --
 18 import { mod2sym1, mod2sym2 } from 'mod2';
 19 import { mod1sym1, mod1sym2 } from 'mod1';
 20 
 21 mod3 = require('mod3');
 22 
 23 printf("root: %.J\n", { mod1sym1, mod1sym2, mod2sym1, mod2sym2, mod3 });
 24 -- End --
 25 
 26 -- File mod1.uc --
 27 export const mod1sym1 = "a";
 28 export const mod1sym2 = "b";
 29 -- End --
 30 
 31 -- File mod2.uc --
 32 export const mod2sym1 = "c";
 33 export const mod2sym2 = "d";
 34 -- End --
 35 
 36 -- File mod3.uc --
 37 import { mod1sym2, mod1sym1 } from 'mod1';
 38 import { mod2sym2, mod2sym1 } from 'mod2';
 39 
 40 printf("mod3: %.J\n", { mod1sym1, mod1sym2, mod2sym1, mod2sym2 });
 41 
 42 return { mod1sym1, mod1sym2, mod2sym1, mod2sym2 };
 43 -- End --
 44 
 45 -- Args --
 46 -R -L files/
 47 -- End --
 48 
 49 -- Expect stdout --
 50 mod3: {
 51         "mod1sym1": "a",
 52         "mod1sym2": "b",
 53         "mod2sym1": "c",
 54         "mod2sym2": "d"
 55 }
 56 root: {
 57         "mod1sym1": "a",
 58         "mod1sym2": "b",
 59         "mod2sym1": "c",
 60         "mod2sym2": "d",
 61         "mod3": {
 62                 "mod1sym1": "a",
 63                 "mod1sym2": "b",
 64                 "mod2sym1": "c",
 65                 "mod2sym2": "d"
 66         }
 67 }
 68 -- End --
 69 
 70 
 71 A variation of the above testcase using wildcard imports.
 72 
 73 root
 74  + import: mod4
 75  + import: mod5
 76  + require: mod6
 77     + import: mod4
 78     + import: mod5
 79 
 80 -- Testcase --
 81 import * as mod5 from 'mod5';
 82 import * as mod4 from 'mod4';
 83 
 84 mod6 = require('mod6');
 85 
 86 printf("root: %.J\n", { mod4, mod5, mod6 });
 87 -- End --
 88 
 89 -- File mod4.uc --
 90 export const sym1 = "a";
 91 export const sym2 = "b";
 92 -- End --
 93 
 94 -- File mod5.uc --
 95 export const sym1 = "c";
 96 export const sym2 = "d";
 97 -- End --
 98 
 99 -- File mod6.uc --
100 import * as mod4 from 'mod4';
101 import * as mod5 from 'mod5';
102 
103 printf("mod6: %.J\n", { mod4, mod5 });
104 
105 return { mod4, mod5 };
106 -- End --
107 
108 -- Args --
109 -R -L files/
110 -- End --
111 
112 -- Expect stdout --
113 mod6: {
114         "mod4": {
115                 "sym1": "a",
116                 "sym2": "b"
117         },
118         "mod5": {
119                 "sym1": "c",
120                 "sym2": "d"
121         }
122 }
123 root: {
124         "mod4": {
125                 "sym1": "a",
126                 "sym2": "b"
127         },
128         "mod5": {
129                 "sym1": "c",
130                 "sym2": "d"
131         },
132         "mod6": {
133                 "mod4": {
134                         "sym1": "a",
135                         "sym2": "b"
136                 },
137                 "mod5": {
138                         "sym1": "c",
139                         "sym2": "d"
140                 }
141         }
142 }
143 -- End --

This page was automatically generated by LXR 0.3.1.  •  OpenWrt