comparison truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/vm/ImplicitExplicitExportTest.java @ 22104:cf19259edf87

TruffleVM.eval and Source.withMimeType
author Jaroslav Tulach <jaroslav.tulach@oracle.com>
date Mon, 24 Aug 2015 08:46:21 +0200
parents 1e78795e7e6a
children d045a505c2b3
comparison
equal deleted inserted replaced
22103:7646278cca8a 22104:cf19259edf87
50 } 50 }
51 51
52 @Test 52 @Test
53 public void explicitExportFound() throws IOException { 53 public void explicitExportFound() throws IOException {
54 // @formatter:off 54 // @formatter:off
55 vm.eval(L1, 55 vm.eval(Source.fromText("explicit.ahoj=42", "Fourty two").withMimeType(L1));
56 "explicit.ahoj=42" 56 Object ret = vm.eval(
57 ); 57 Source.fromText("return=ahoj", "Return").withMimeType(L3)
58 Object ret = vm.eval(L3,
59 "return=ahoj"
60 ); 58 );
61 // @formatter:on 59 // @formatter:on
62 assertEquals("42", ret); 60 assertEquals("42", ret);
63 } 61 }
64 62
65 @Test 63 @Test
66 public void implicitExportFound() throws IOException { 64 public void implicitExportFound() throws IOException {
67 // @formatter:off 65 // @formatter:off
68 vm.eval(L1, 66 vm.eval(
69 "implicit.ahoj=42" 67 Source.fromText("implicit.ahoj=42", "Fourty two").withMimeType(L1)
70 ); 68 );
71 Object ret = vm.eval(L3, 69 Object ret = vm.eval(
72 "return=ahoj" 70 Source.fromText("return=ahoj", "Return").withMimeType(L3)
73 ); 71 );
74 // @formatter:on 72 // @formatter:on
75 assertEquals("42", ret); 73 assertEquals("42", ret);
76 } 74 }
77 75
78 @Test 76 @Test
79 public void explicitExportPreferred2() throws IOException { 77 public void explicitExportPreferred2() throws IOException {
80 // @formatter:off 78 // @formatter:off
81 vm.eval(L1, 79 vm.eval(
82 "implicit.ahoj=42" 80 Source.fromText("implicit.ahoj=42", "Fourty two").withMimeType(L1)
83 ); 81 );
84 vm.eval(L2, 82 vm.eval(
85 "explicit.ahoj=43" 83 Source.fromText("explicit.ahoj=43", "Fourty three").withMimeType(L2)
86 ); 84 );
87 Object ret = vm.eval(L3, 85 Object ret = vm.eval(
88 "return=ahoj" 86 Source.fromText("return=ahoj", "Return").withMimeType(L3)
89 ); 87 );
90 // @formatter:on 88 // @formatter:on
91 assertEquals("Explicit import from L2 is used", "43", ret); 89 assertEquals("Explicit import from L2 is used", "43", ret);
92 assertEquals("Global symbol is also 43", "43", vm.findGlobalSymbol("ahoj").invoke(null)); 90 assertEquals("Global symbol is also 43", "43", vm.findGlobalSymbol("ahoj").invoke(null));
93 } 91 }
94 92
95 @Test 93 @Test
96 public void explicitExportPreferred1() throws IOException { 94 public void explicitExportPreferred1() throws IOException {
97 // @formatter:off 95 // @formatter:off
98 vm.eval(L1, 96 vm.eval(
99 "explicit.ahoj=43" 97 Source.fromText("explicit.ahoj=43", "Fourty three").withMimeType(L1)
100 ); 98 );
101 vm.eval(L2, 99 vm.eval(
102 "implicit.ahoj=42" 100 Source.fromText("implicit.ahoj=42", "Fourty two").withMimeType(L2)
103 ); 101 );
104 Object ret = vm.eval(L3, 102 Object ret = vm.eval(
105 "return=ahoj" 103 Source.fromText("return=ahoj", "Return").withMimeType(L3)
106 ); 104 );
107 // @formatter:on 105 // @formatter:on
108 assertEquals("Explicit import from L2 is used", "43", ret); 106 assertEquals("Explicit import from L2 is used", "43", ret);
109 assertEquals("Global symbol is also 43", "43", vm.findGlobalSymbol("ahoj").invoke(null)); 107 assertEquals("Global symbol is also 43", "43", vm.findGlobalSymbol("ahoj").invoke(null));
110 } 108 }