Mercurial > hg > truffle
comparison truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/vm/ToStringTest.java @ 22424:fec62e298245
Rename package truffle.api.test to truffle.api to enable package-protected API access for testing.
author | Christian Humer <christian.humer@oracle.com> |
---|---|
date | Wed, 02 Dec 2015 15:16:27 +0100 |
parents | truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/vm/ToStringTest.java@906a5f6e07cc |
children | b39b603e2a1e |
comparison
equal
deleted
inserted
replaced
22423:70a10a9f28ad | 22424:fec62e298245 |
---|---|
1 /* | |
2 * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. | |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
4 * | |
5 * This code is free software; you can redistribute it and/or modify it | |
6 * under the terms of the GNU General Public License version 2 only, as | |
7 * published by the Free Software Foundation. | |
8 * | |
9 * This code is distributed in the hope that it will be useful, but WITHOUT | |
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
12 * version 2 for more details (a copy is included in the LICENSE file that | |
13 * accompanied this code). | |
14 * | |
15 * You should have received a copy of the GNU General Public License version | |
16 * 2 along with this work; if not, write to the Free Software Foundation, | |
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
18 * | |
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
20 * or visit www.oracle.com if you need additional information or have any | |
21 * questions. | |
22 */ | |
23 package com.oracle.truffle.api.vm; | |
24 | |
25 import com.oracle.truffle.api.source.Source; | |
26 import com.oracle.truffle.api.vm.PolyglotEngine; | |
27 import static org.junit.Assert.assertEquals; | |
28 import org.junit.Test; | |
29 | |
30 public class ToStringTest { | |
31 @Test | |
32 public void valueToStringValueWith1() throws Exception { | |
33 PolyglotEngine engine = PolyglotEngine.newBuilder().build(); | |
34 PolyglotEngine.Language language1 = engine.getLanguages().get("application/x-test-import-export-1"); | |
35 PolyglotEngine.Language language2 = engine.getLanguages().get("application/x-test-import-export-2"); | |
36 language2.eval(Source.fromText("explicit.value=42", "define 42")); | |
37 PolyglotEngine.Value value = language1.eval(Source.fromText("return=value", "42.value")); | |
38 assertEquals("It's fourtytwo", "42", value.get()); | |
39 | |
40 String textual = value.as(String.class); | |
41 assertEquals("Nicely formated as by L1", "42: Int", textual); | |
42 } | |
43 | |
44 @Test | |
45 public void valueToStringValueWith2() throws Exception { | |
46 PolyglotEngine engine = PolyglotEngine.newBuilder().build(); | |
47 PolyglotEngine.Language language1 = engine.getLanguages().get("application/x-test-import-export-1"); | |
48 PolyglotEngine.Language language2 = engine.getLanguages().get("application/x-test-import-export-2"); | |
49 language1.eval(Source.fromText("explicit.value=42", "define 42")); | |
50 PolyglotEngine.Value value = language2.eval(Source.fromText("return=value", "42.value")); | |
51 assertEquals("It's fourtytwo", "42", value.get()); | |
52 | |
53 String textual = value.as(String.class); | |
54 assertEquals("Nicely formated as by L2", "42.0: Double", textual); | |
55 } | |
56 | |
57 } |