Mercurial > hg > truffle
annotate truffle/com.oracle.truffle.tck/src/com/oracle/truffle/tck/TruffleTCK.java @ 22544:9aded7e1e122
When integer values are on input of any language, the result should be the same regardless they are stored as int or float or double
author | Jaroslav Tulach <jaroslav.tulach@oracle.com> |
---|---|
date | Thu, 07 Jan 2016 16:06:31 +0100 |
parents | 0ef597d27256 |
children | 17fe5ef92696 |
rev | line source |
---|---|
21938
0a6e10379b9b
Keeping only Truffle-related modules in this repository
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
1 /* |
0a6e10379b9b
Keeping only Truffle-related modules in this repository
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
2 * Copyright (c) 2015, 2015, Oracle and/or its affiliates. All rights reserved. |
0a6e10379b9b
Keeping only Truffle-related modules in this repository
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
0a6e10379b9b
Keeping only Truffle-related modules in this repository
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
4 * |
0a6e10379b9b
Keeping only Truffle-related modules in this repository
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
0a6e10379b9b
Keeping only Truffle-related modules in this repository
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
0a6e10379b9b
Keeping only Truffle-related modules in this repository
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. Oracle designates this |
0a6e10379b9b
Keeping only Truffle-related modules in this repository
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
8 * particular file as subject to the "Classpath" exception as provided |
0a6e10379b9b
Keeping only Truffle-related modules in this repository
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
9 * by Oracle in the LICENSE file that accompanied this code. |
0a6e10379b9b
Keeping only Truffle-related modules in this repository
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
10 * |
0a6e10379b9b
Keeping only Truffle-related modules in this repository
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
11 * This code is distributed in the hope that it will be useful, but WITHOUT |
0a6e10379b9b
Keeping only Truffle-related modules in this repository
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
0a6e10379b9b
Keeping only Truffle-related modules in this repository
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
0a6e10379b9b
Keeping only Truffle-related modules in this repository
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
14 * version 2 for more details (a copy is included in the LICENSE file that |
0a6e10379b9b
Keeping only Truffle-related modules in this repository
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
15 * accompanied this code). |
0a6e10379b9b
Keeping only Truffle-related modules in this repository
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
16 * |
0a6e10379b9b
Keeping only Truffle-related modules in this repository
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
17 * You should have received a copy of the GNU General Public License version |
0a6e10379b9b
Keeping only Truffle-related modules in this repository
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
18 * 2 along with this work; if not, write to the Free Software Foundation, |
0a6e10379b9b
Keeping only Truffle-related modules in this repository
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
0a6e10379b9b
Keeping only Truffle-related modules in this repository
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
20 * |
0a6e10379b9b
Keeping only Truffle-related modules in this repository
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
0a6e10379b9b
Keeping only Truffle-related modules in this repository
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
22 * or visit www.oracle.com if you need additional information or have any |
0a6e10379b9b
Keeping only Truffle-related modules in this repository
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
23 * questions. |
0a6e10379b9b
Keeping only Truffle-related modules in this repository
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
24 */ |
0a6e10379b9b
Keeping only Truffle-related modules in this repository
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
25 package com.oracle.truffle.tck; |
0a6e10379b9b
Keeping only Truffle-related modules in this repository
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
26 |
22525
89db2519ef18
Moving implementation classes outside of the tck package to make the Javadoc of the TCK API cleaner
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22524
diff
changeset
|
27 import com.oracle.truffle.tck.impl.LongBinaryOperation; |
89db2519ef18
Moving implementation classes outside of the tck package to make the Javadoc of the TCK API cleaner
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22524
diff
changeset
|
28 import com.oracle.truffle.tck.impl.ObjectBinaryOperation; |
21938
0a6e10379b9b
Keeping only Truffle-related modules in this repository
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
29 |
22495
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
30 import java.io.IOException; |
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
31 import java.lang.reflect.Field; |
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
32 import java.nio.ByteBuffer; |
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
33 import java.util.Arrays; |
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
34 import java.util.Random; |
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
35 |
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
36 import org.junit.Assert; |
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
37 import org.junit.Test; |
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
38 |
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
39 import com.oracle.truffle.api.TruffleLanguage; |
22524
579d21e36582
Including documentation for the TCK in the unified Javadoc
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22523
diff
changeset
|
40 import com.oracle.truffle.api.interop.ForeignAccess.Factory10; |
579d21e36582
Including documentation for the TCK in the unified Javadoc
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22523
diff
changeset
|
41 import com.oracle.truffle.api.interop.Message; |
22495
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
42 import com.oracle.truffle.api.interop.TruffleObject; |
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
43 import com.oracle.truffle.api.interop.java.JavaInterop; |
22523
6ab540203853
Expanding TCK to cover reading and writing of object properties with various primitive types
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22496
diff
changeset
|
44 import com.oracle.truffle.api.interop.java.MethodMessage; |
22524
579d21e36582
Including documentation for the TCK in the unified Javadoc
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22523
diff
changeset
|
45 import com.oracle.truffle.api.nodes.RootNode; |
22495
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
46 import com.oracle.truffle.api.source.Source; |
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
47 import com.oracle.truffle.api.vm.PolyglotEngine; |
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
48 import com.oracle.truffle.api.vm.PolyglotEngine.Language; |
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
49 import com.oracle.truffle.tck.Schema.Type; |
22542
f8fb609939a7
Give implementors of the TCK control over comparing doubles.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22525
diff
changeset
|
50 import static org.junit.Assert.assertEquals; |
f8fb609939a7
Give implementors of the TCK control over comparing doubles.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22525
diff
changeset
|
51 import static org.junit.Assert.assertNotNull; |
f8fb609939a7
Give implementors of the TCK control over comparing doubles.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22525
diff
changeset
|
52 import static org.junit.Assert.assertNotSame; |
f8fb609939a7
Give implementors of the TCK control over comparing doubles.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22525
diff
changeset
|
53 import static org.junit.Assert.assertNull; |
f8fb609939a7
Give implementors of the TCK control over comparing doubles.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22525
diff
changeset
|
54 import static org.junit.Assert.assertSame; |
f8fb609939a7
Give implementors of the TCK control over comparing doubles.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22525
diff
changeset
|
55 import static org.junit.Assert.assertTrue; |
f8fb609939a7
Give implementors of the TCK control over comparing doubles.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22525
diff
changeset
|
56 import static org.junit.Assert.fail; |
22495
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
57 |
21938
0a6e10379b9b
Keeping only Truffle-related modules in this repository
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
58 /** |
22524
579d21e36582
Including documentation for the TCK in the unified Javadoc
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22523
diff
changeset
|
59 * Test compatibility kit (the <em>TCK</em>) is a collection of tests to certify your |
579d21e36582
Including documentation for the TCK in the unified Javadoc
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22523
diff
changeset
|
60 * {@link TruffleLanguage language implementation} compliance. If you want your language to be |
579d21e36582
Including documentation for the TCK in the unified Javadoc
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22523
diff
changeset
|
61 * compliant with most recent requirements of the Truffle infrastructure and tooling, subclass, |
579d21e36582
Including documentation for the TCK in the unified Javadoc
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22523
diff
changeset
|
62 * implement <b>protected</b> methods and include in your test suite: |
579d21e36582
Including documentation for the TCK in the unified Javadoc
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22523
diff
changeset
|
63 * |
579d21e36582
Including documentation for the TCK in the unified Javadoc
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22523
diff
changeset
|
64 * <pre> |
579d21e36582
Including documentation for the TCK in the unified Javadoc
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22523
diff
changeset
|
65 * <b>public class</b> MyLanguageTCKTest <b>extends</b> {@link TruffleTCK} { |
579d21e36582
Including documentation for the TCK in the unified Javadoc
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22523
diff
changeset
|
66 * {@link Override @Override} |
579d21e36582
Including documentation for the TCK in the unified Javadoc
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22523
diff
changeset
|
67 * <b>protected</b> {@link PolyglotEngine} {@link #prepareVM() prepareVM}() { |
579d21e36582
Including documentation for the TCK in the unified Javadoc
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22523
diff
changeset
|
68 * <em>// create the engine</em> |
579d21e36582
Including documentation for the TCK in the unified Javadoc
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22523
diff
changeset
|
69 * <em>// execute necessary scripts</em> |
579d21e36582
Including documentation for the TCK in the unified Javadoc
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22523
diff
changeset
|
70 * } |
579d21e36582
Including documentation for the TCK in the unified Javadoc
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22523
diff
changeset
|
71 * |
579d21e36582
Including documentation for the TCK in the unified Javadoc
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22523
diff
changeset
|
72 * {@link Override @Override} |
579d21e36582
Including documentation for the TCK in the unified Javadoc
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22523
diff
changeset
|
73 * <b>protected</b> {@link String} fourtyTwo() { |
579d21e36582
Including documentation for the TCK in the unified Javadoc
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22523
diff
changeset
|
74 * <b>return</b> <em>// name of function that returns 42</em> |
579d21e36582
Including documentation for the TCK in the unified Javadoc
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22523
diff
changeset
|
75 * } |
579d21e36582
Including documentation for the TCK in the unified Javadoc
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22523
diff
changeset
|
76 * |
579d21e36582
Including documentation for the TCK in the unified Javadoc
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22523
diff
changeset
|
77 * <em>// and so on...</em> |
579d21e36582
Including documentation for the TCK in the unified Javadoc
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22523
diff
changeset
|
78 * } |
579d21e36582
Including documentation for the TCK in the unified Javadoc
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22523
diff
changeset
|
79 * </pre> |
579d21e36582
Including documentation for the TCK in the unified Javadoc
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22523
diff
changeset
|
80 * |
579d21e36582
Including documentation for the TCK in the unified Javadoc
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22523
diff
changeset
|
81 * The <em>TCK</em> is carefully designed to accommodate differences between languages. The |
579d21e36582
Including documentation for the TCK in the unified Javadoc
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22523
diff
changeset
|
82 * <em>TCK</em> doesn't dictate what object your language is using to represent {@link Number |
579d21e36582
Including documentation for the TCK in the unified Javadoc
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22523
diff
changeset
|
83 * numbers} or {@link String strings} internally. The <em>TCK</em> doesn't prescribe the precise |
579d21e36582
Including documentation for the TCK in the unified Javadoc
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22523
diff
changeset
|
84 * type of values returned from your |
579d21e36582
Including documentation for the TCK in the unified Javadoc
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22523
diff
changeset
|
85 * {@link PolyglotEngine#eval(com.oracle.truffle.api.source.Source) language evaluations}. The tests |
579d21e36582
Including documentation for the TCK in the unified Javadoc
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22523
diff
changeset
|
86 * just assume that if the result is supposed to be a number, the returned value will be an instance |
579d21e36582
Including documentation for the TCK in the unified Javadoc
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22523
diff
changeset
|
87 * of {@link Number} or be {@link Message#UNBOX convertible} to a {@link Number} and keeps |
579d21e36582
Including documentation for the TCK in the unified Javadoc
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22523
diff
changeset
|
88 * sufficient level of precision. Similarly for {@link String strings}. As such the tests in the |
579d21e36582
Including documentation for the TCK in the unified Javadoc
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22523
diff
changeset
|
89 * <em>TCK</em> should be applicable to wide range of languages. Should there be a test that cannot |
579d21e36582
Including documentation for the TCK in the unified Javadoc
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22523
diff
changeset
|
90 * be implemented in your language, it can be suppressed by overriding its test method and doing |
579d21e36582
Including documentation for the TCK in the unified Javadoc
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22523
diff
changeset
|
91 * nothing: |
579d21e36582
Including documentation for the TCK in the unified Javadoc
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22523
diff
changeset
|
92 * |
579d21e36582
Including documentation for the TCK in the unified Javadoc
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22523
diff
changeset
|
93 * <pre> |
579d21e36582
Including documentation for the TCK in the unified Javadoc
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22523
diff
changeset
|
94 * {@link Override @Override} |
579d21e36582
Including documentation for the TCK in the unified Javadoc
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22523
diff
changeset
|
95 * <b>public void</b> {@link #testFortyTwo() testFortyTwo}() { |
579d21e36582
Including documentation for the TCK in the unified Javadoc
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22523
diff
changeset
|
96 * <em>// do nothing</em> |
579d21e36582
Including documentation for the TCK in the unified Javadoc
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22523
diff
changeset
|
97 * } |
579d21e36582
Including documentation for the TCK in the unified Javadoc
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22523
diff
changeset
|
98 * </pre> |
579d21e36582
Including documentation for the TCK in the unified Javadoc
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22523
diff
changeset
|
99 * <p> |
579d21e36582
Including documentation for the TCK in the unified Javadoc
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22523
diff
changeset
|
100 * The primary goal of the <em>TCK</em> is to ensure your {@link TruffleLanguage language |
579d21e36582
Including documentation for the TCK in the unified Javadoc
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22523
diff
changeset
|
101 * implementation} plays well with other languages in the {@link PolyglotEngine} - e.g. that data |
579d21e36582
Including documentation for the TCK in the unified Javadoc
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22523
diff
changeset
|
102 * can be exchanged between your and other languages. The {@link com.oracle.truffle.api.interop |
579d21e36582
Including documentation for the TCK in the unified Javadoc
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22523
diff
changeset
|
103 * interop package} defines what types of data can be interchanged between the languages and the |
579d21e36582
Including documentation for the TCK in the unified Javadoc
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22523
diff
changeset
|
104 * <em>TCK</em> does its best to make sure all these data are really accepted as an input on a |
579d21e36582
Including documentation for the TCK in the unified Javadoc
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22523
diff
changeset
|
105 * boundary of your {@link TruffleLanguage language implementation}. That doesn't mean such data |
579d21e36582
Including documentation for the TCK in the unified Javadoc
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22523
diff
changeset
|
106 * need to be used internally, many languages do conversions in their {@link Factory10 foreign |
579d21e36582
Including documentation for the TCK in the unified Javadoc
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22523
diff
changeset
|
107 * access} {@link RootNode nodes} to more suitable internal representation. Such conversion is fully |
579d21e36582
Including documentation for the TCK in the unified Javadoc
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22523
diff
changeset
|
108 * acceptable as nobody prescribes what is the actual type of output after executing a function/code |
579d21e36582
Including documentation for the TCK in the unified Javadoc
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22523
diff
changeset
|
109 * snippet in your language. |
579d21e36582
Including documentation for the TCK in the unified Javadoc
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22523
diff
changeset
|
110 * <p> |
579d21e36582
Including documentation for the TCK in the unified Javadoc
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22523
diff
changeset
|
111 * Should the <em>TCK</em> be found unsuitable for your {@link TruffleLanguage language |
579d21e36582
Including documentation for the TCK in the unified Javadoc
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22523
diff
changeset
|
112 * implementation} please speak-up (at <em>Truffle/Graal</em> mailing list for example) and we do |
579d21e36582
Including documentation for the TCK in the unified Javadoc
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22523
diff
changeset
|
113 * our best to analyze your case and adjust the <em>TCK</em> to suite everyone's needs. |
21938
0a6e10379b9b
Keeping only Truffle-related modules in this repository
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
114 */ |
0a6e10379b9b
Keeping only Truffle-related modules in this repository
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
115 public abstract class TruffleTCK { |
22135
e70b20f4bb00
Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22121
diff
changeset
|
116 private static final Random RANDOM = new Random(); |
22170
796f0fef110e
Renaming to PolyglotEngine
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22168
diff
changeset
|
117 private PolyglotEngine tckVM; |
21938
0a6e10379b9b
Keeping only Truffle-related modules in this repository
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
118 |
0a6e10379b9b
Keeping only Truffle-related modules in this repository
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
119 protected TruffleTCK() { |
0a6e10379b9b
Keeping only Truffle-related modules in this repository
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
120 } |
0a6e10379b9b
Keeping only Truffle-related modules in this repository
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
121 |
0a6e10379b9b
Keeping only Truffle-related modules in this repository
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
122 /** |
22172
b31dcacfc8ff
Replacing more TruffleVM references in comments with the new PolyglotEngine name
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22170
diff
changeset
|
123 * This methods is called before first test is executed. It's purpose is to set a |
b31dcacfc8ff
Replacing more TruffleVM references in comments with the new PolyglotEngine name
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22170
diff
changeset
|
124 * {@link PolyglotEngine} with your language up, so it is ready for testing. |
b31dcacfc8ff
Replacing more TruffleVM references in comments with the new PolyglotEngine name
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22170
diff
changeset
|
125 * {@link PolyglotEngine#eval(com.oracle.truffle.api.source.Source) Execute} any scripts you |
b31dcacfc8ff
Replacing more TruffleVM references in comments with the new PolyglotEngine name
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22170
diff
changeset
|
126 * need, and prepare global symbols with proper names. The symbols will then be looked up by the |
21938
0a6e10379b9b
Keeping only Truffle-related modules in this repository
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
127 * infrastructure (using the names provided by you from methods like {@link #plusInt()}) and |
0a6e10379b9b
Keeping only Truffle-related modules in this repository
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
128 * used for internal testing. |
0a6e10379b9b
Keeping only Truffle-related modules in this repository
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
129 * |
0a6e10379b9b
Keeping only Truffle-related modules in this repository
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
130 * @return initialized Truffle virtual machine |
0a6e10379b9b
Keeping only Truffle-related modules in this repository
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
131 * @throws java.lang.Exception thrown when the VM preparation fails |
0a6e10379b9b
Keeping only Truffle-related modules in this repository
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
132 */ |
22170
796f0fef110e
Renaming to PolyglotEngine
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22168
diff
changeset
|
133 protected abstract PolyglotEngine prepareVM() throws Exception; |
21938
0a6e10379b9b
Keeping only Truffle-related modules in this repository
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
134 |
0a6e10379b9b
Keeping only Truffle-related modules in this repository
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
135 /** |
22135
e70b20f4bb00
Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22121
diff
changeset
|
136 * MIME type associated with your language. The MIME type will be passed to |
22172
b31dcacfc8ff
Replacing more TruffleVM references in comments with the new PolyglotEngine name
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22170
diff
changeset
|
137 * {@link PolyglotEngine#eval(com.oracle.truffle.api.source.Source)} method of the |
b31dcacfc8ff
Replacing more TruffleVM references in comments with the new PolyglotEngine name
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22170
diff
changeset
|
138 * {@link #prepareVM() created engine}. |
21938
0a6e10379b9b
Keeping only Truffle-related modules in this repository
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
139 * |
0a6e10379b9b
Keeping only Truffle-related modules in this repository
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
140 * @return mime type of the tested language |
0a6e10379b9b
Keeping only Truffle-related modules in this repository
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
141 */ |
0a6e10379b9b
Keeping only Truffle-related modules in this repository
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
142 protected abstract String mimeType(); |
0a6e10379b9b
Keeping only Truffle-related modules in this repository
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
143 |
0a6e10379b9b
Keeping only Truffle-related modules in this repository
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
144 /** |
0a6e10379b9b
Keeping only Truffle-related modules in this repository
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
145 * Name of function which will return value 42 as a number. The return value of the method |
0a6e10379b9b
Keeping only Truffle-related modules in this repository
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
146 * should be instance of {@link Number} and its {@link Number#intValue()} should return |
0a6e10379b9b
Keeping only Truffle-related modules in this repository
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
147 * <code>42</code>. |
0a6e10379b9b
Keeping only Truffle-related modules in this repository
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
148 * |
0a6e10379b9b
Keeping only Truffle-related modules in this repository
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
149 * @return name of globally exported symbol |
0a6e10379b9b
Keeping only Truffle-related modules in this repository
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
150 */ |
0a6e10379b9b
Keeping only Truffle-related modules in this repository
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
151 protected abstract String fourtyTwo(); |
0a6e10379b9b
Keeping only Truffle-related modules in this repository
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
152 |
0a6e10379b9b
Keeping only Truffle-related modules in this repository
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
153 /** |
0a6e10379b9b
Keeping only Truffle-related modules in this repository
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
154 * Name of a function that returns <code>null</code>. Truffle languages are encouraged to have |
0a6e10379b9b
Keeping only Truffle-related modules in this repository
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
155 * their own type representing <code>null</code>, but when such value is returned from |
22172
b31dcacfc8ff
Replacing more TruffleVM references in comments with the new PolyglotEngine name
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22170
diff
changeset
|
156 * {@link PolyglotEngine#eval}, it needs to be converted to real Java <code>null</code> by |
b31dcacfc8ff
Replacing more TruffleVM references in comments with the new PolyglotEngine name
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22170
diff
changeset
|
157 * sending a foreign access <em>isNull</em> message. There is a test to verify it is really |
b31dcacfc8ff
Replacing more TruffleVM references in comments with the new PolyglotEngine name
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22170
diff
changeset
|
158 * true. |
21938
0a6e10379b9b
Keeping only Truffle-related modules in this repository
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
159 * |
0a6e10379b9b
Keeping only Truffle-related modules in this repository
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
160 * @return name of globally exported symbol |
0a6e10379b9b
Keeping only Truffle-related modules in this repository
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
161 */ |
0a6e10379b9b
Keeping only Truffle-related modules in this repository
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
162 protected abstract String returnsNull(); |
0a6e10379b9b
Keeping only Truffle-related modules in this repository
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
163 |
0a6e10379b9b
Keeping only Truffle-related modules in this repository
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
164 /** |
0a6e10379b9b
Keeping only Truffle-related modules in this repository
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
165 * Name of function to add two integer values together. The symbol will be invoked with two |
0a6e10379b9b
Keeping only Truffle-related modules in this repository
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
166 * parameters of type {@link Integer} and expects result of type {@link Number} which's |
0a6e10379b9b
Keeping only Truffle-related modules in this repository
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
167 * {@link Number#intValue()} is equivalent of <code>param1 + param2</code>. |
0a6e10379b9b
Keeping only Truffle-related modules in this repository
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
168 * |
0a6e10379b9b
Keeping only Truffle-related modules in this repository
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
169 * @return name of globally exported symbol |
0a6e10379b9b
Keeping only Truffle-related modules in this repository
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
170 */ |
22138
a583d7ffd285
Enhancing TCK to pass in all Java number types and see whether they result in something meaningful.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22135
diff
changeset
|
171 protected String plusInt() { |
a583d7ffd285
Enhancing TCK to pass in all Java number types and see whether they result in something meaningful.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22135
diff
changeset
|
172 throw new UnsupportedOperationException("Override plus(Class,Class) method!"); |
a583d7ffd285
Enhancing TCK to pass in all Java number types and see whether they result in something meaningful.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22135
diff
changeset
|
173 } |
a583d7ffd285
Enhancing TCK to pass in all Java number types and see whether they result in something meaningful.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22135
diff
changeset
|
174 |
a583d7ffd285
Enhancing TCK to pass in all Java number types and see whether they result in something meaningful.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22135
diff
changeset
|
175 /** |
a583d7ffd285
Enhancing TCK to pass in all Java number types and see whether they result in something meaningful.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22135
diff
changeset
|
176 * Name of function to add two numbers together. The symbol will be invoked with two parameters |
22523
6ab540203853
Expanding TCK to cover reading and writing of object properties with various primitive types
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22496
diff
changeset
|
177 * of <code>type1</code> and <code>type2</code> and expects result of type {@link Number} |
22138
a583d7ffd285
Enhancing TCK to pass in all Java number types and see whether they result in something meaningful.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22135
diff
changeset
|
178 * which's {@link Number#intValue()} is equivalent of <code>param1 + param2</code>. As some |
a583d7ffd285
Enhancing TCK to pass in all Java number types and see whether they result in something meaningful.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22135
diff
changeset
|
179 * languages may have different operations for different types of numbers, the actual types are |
a583d7ffd285
Enhancing TCK to pass in all Java number types and see whether they result in something meaningful.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22135
diff
changeset
|
180 * passed to the method and the implementation can decide to return different symbol based on |
a583d7ffd285
Enhancing TCK to pass in all Java number types and see whether they result in something meaningful.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22135
diff
changeset
|
181 * the parameters. |
a583d7ffd285
Enhancing TCK to pass in all Java number types and see whether they result in something meaningful.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22135
diff
changeset
|
182 * |
a583d7ffd285
Enhancing TCK to pass in all Java number types and see whether they result in something meaningful.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22135
diff
changeset
|
183 * @param type1 one of byte, short, int, long, float, double class |
a583d7ffd285
Enhancing TCK to pass in all Java number types and see whether they result in something meaningful.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22135
diff
changeset
|
184 * @param type2 one of byte, short, int, long, float, double class |
a583d7ffd285
Enhancing TCK to pass in all Java number types and see whether they result in something meaningful.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22135
diff
changeset
|
185 * @return name of globally exported symbol |
a583d7ffd285
Enhancing TCK to pass in all Java number types and see whether they result in something meaningful.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22135
diff
changeset
|
186 */ |
a583d7ffd285
Enhancing TCK to pass in all Java number types and see whether they result in something meaningful.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22135
diff
changeset
|
187 protected String plus(Class<?> type1, Class<?> type2) { |
a583d7ffd285
Enhancing TCK to pass in all Java number types and see whether they result in something meaningful.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22135
diff
changeset
|
188 return plusInt(); |
a583d7ffd285
Enhancing TCK to pass in all Java number types and see whether they result in something meaningful.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22135
diff
changeset
|
189 } |
21938
0a6e10379b9b
Keeping only Truffle-related modules in this repository
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
190 |
0a6e10379b9b
Keeping only Truffle-related modules in this repository
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
191 /** |
21960
a88981c5ce8b
Initial test for Java Interop: Perform callback to Math.min and Math.max via TruffleObject and Message.createExecute(2).
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21951
diff
changeset
|
192 * Name of a function in your language to perform a callback to foreign function. Your function |
a88981c5ce8b
Initial test for Java Interop: Perform callback to Math.min and Math.max via TruffleObject and Message.createExecute(2).
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21951
diff
changeset
|
193 * should prepare two numbers (18 and 32) and apply them to the function passed in as an |
a88981c5ce8b
Initial test for Java Interop: Perform callback to Math.min and Math.max via TruffleObject and Message.createExecute(2).
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21951
diff
changeset
|
194 * argument of your function. It should then add 10 to the returned value and return the result |
a88981c5ce8b
Initial test for Java Interop: Perform callback to Math.min and Math.max via TruffleObject and Message.createExecute(2).
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21951
diff
changeset
|
195 * back to its caller. |
a88981c5ce8b
Initial test for Java Interop: Perform callback to Math.min and Math.max via TruffleObject and Message.createExecute(2).
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21951
diff
changeset
|
196 * |
a88981c5ce8b
Initial test for Java Interop: Perform callback to Math.min and Math.max via TruffleObject and Message.createExecute(2).
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21951
diff
changeset
|
197 * @return name of globally exported symbol |
a88981c5ce8b
Initial test for Java Interop: Perform callback to Math.min and Math.max via TruffleObject and Message.createExecute(2).
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21951
diff
changeset
|
198 */ |
a88981c5ce8b
Initial test for Java Interop: Perform callback to Math.min and Math.max via TruffleObject and Message.createExecute(2).
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21951
diff
changeset
|
199 protected abstract String applyNumbers(); |
a88981c5ce8b
Initial test for Java Interop: Perform callback to Math.min and Math.max via TruffleObject and Message.createExecute(2).
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21951
diff
changeset
|
200 |
a88981c5ce8b
Initial test for Java Interop: Perform callback to Math.min and Math.max via TruffleObject and Message.createExecute(2).
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21951
diff
changeset
|
201 /** |
22140
92906003d607
Adding check of behavior of identity function into the TCK
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22139
diff
changeset
|
202 * Name of identity function. The identity function accepts one argument and returns it. The |
92906003d607
Adding check of behavior of identity function into the TCK
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22139
diff
changeset
|
203 * argument should go through without any modification, e.g. the input should result in |
92906003d607
Adding check of behavior of identity function into the TCK
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22139
diff
changeset
|
204 * identical output. |
92906003d607
Adding check of behavior of identity function into the TCK
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22139
diff
changeset
|
205 * |
92906003d607
Adding check of behavior of identity function into the TCK
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22139
diff
changeset
|
206 * @return name of globally exported symbol |
92906003d607
Adding check of behavior of identity function into the TCK
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22139
diff
changeset
|
207 */ |
92906003d607
Adding check of behavior of identity function into the TCK
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22139
diff
changeset
|
208 protected String identity() { |
22156
50056a161d7f
Replacing time out associated warnings by UnsupportedOperationException. Meaning of exception is probably more straightforward than a soft hint attempted before. Shouldn't influence the way things are build, if tests are skipped.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22142
diff
changeset
|
209 throw new UnsupportedOperationException("identity() method not implemented"); |
22140
92906003d607
Adding check of behavior of identity function into the TCK
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22139
diff
changeset
|
210 } |
92906003d607
Adding check of behavior of identity function into the TCK
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22139
diff
changeset
|
211 |
92906003d607
Adding check of behavior of identity function into the TCK
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22139
diff
changeset
|
212 /** |
22488
fa7b15454c66
Add ComplexNumber test to TCK
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22437
diff
changeset
|
213 * Name of a function that adds up two complex numbers. The function accepts two arguments and |
fa7b15454c66
Add ComplexNumber test to TCK
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22437
diff
changeset
|
214 * provides no return value. The arguments are complex numbers with members called real and |
fa7b15454c66
Add ComplexNumber test to TCK
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22437
diff
changeset
|
215 * imaginary. The first argument contains the result of the addition. |
fa7b15454c66
Add ComplexNumber test to TCK
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22437
diff
changeset
|
216 * |
fa7b15454c66
Add ComplexNumber test to TCK
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22437
diff
changeset
|
217 * @return name of globally exported symbol |
fa7b15454c66
Add ComplexNumber test to TCK
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22437
diff
changeset
|
218 */ |
fa7b15454c66
Add ComplexNumber test to TCK
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22437
diff
changeset
|
219 protected String complexAdd() { |
fa7b15454c66
Add ComplexNumber test to TCK
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22437
diff
changeset
|
220 throw new UnsupportedOperationException("complexAdd() method not implemented"); |
fa7b15454c66
Add ComplexNumber test to TCK
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22437
diff
changeset
|
221 } |
fa7b15454c66
Add ComplexNumber test to TCK
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22437
diff
changeset
|
222 |
fa7b15454c66
Add ComplexNumber test to TCK
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22437
diff
changeset
|
223 /** |
22495
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
224 * Name of a function that adds up the real part of complex numbers. The function accepts one |
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
225 * argument and provides the sum of all real parts. The argument is an array/buffer of complex |
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
226 * numbers. |
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
227 * |
22542
f8fb609939a7
Give implementors of the TCK control over comparing doubles.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22525
diff
changeset
|
228 * @return name of globally exported symbol, <code>null</code> if the test should be skipped |
22495
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
229 */ |
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
230 protected String complexSumReal() { |
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
231 throw new UnsupportedOperationException("complexSumReal() method not implemented"); |
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
232 } |
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
233 |
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
234 /** |
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
235 * Name of a function that copies a list of complex numbers. The function accepts two arguments |
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
236 * and provides no return value. The arguments are two lists of complex numbers with members |
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
237 * called real and imaginary. The first argument is the destination, the second argument is the |
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
238 * source. |
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
239 * |
22542
f8fb609939a7
Give implementors of the TCK control over comparing doubles.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22525
diff
changeset
|
240 * @return name of globally exported symbol, <code>null</code> if the test should be skipped |
22495
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
241 */ |
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
242 protected String complexCopy() { |
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
243 throw new UnsupportedOperationException("complexCopy() method not implemented"); |
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
244 } |
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
245 |
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
246 /** |
22278
85a6db6624ab
Simplifying the way to obtain Language.globalObject
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22200
diff
changeset
|
247 * Name of a function to return global object. The function can be executed without providing |
85a6db6624ab
Simplifying the way to obtain Language.globalObject
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22200
diff
changeset
|
248 * any arguments and should return global object of the language, if the language supports it. |
85a6db6624ab
Simplifying the way to obtain Language.globalObject
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22200
diff
changeset
|
249 * Global object is the one accessible via |
85a6db6624ab
Simplifying the way to obtain Language.globalObject
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22200
diff
changeset
|
250 * {@link TruffleLanguage#getLanguageGlobal(java.lang.Object)}. |
85a6db6624ab
Simplifying the way to obtain Language.globalObject
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22200
diff
changeset
|
251 * |
85a6db6624ab
Simplifying the way to obtain Language.globalObject
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22200
diff
changeset
|
252 * @return name of globally exported symbol, return <code>null</code> if the language doesn't |
85a6db6624ab
Simplifying the way to obtain Language.globalObject
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22200
diff
changeset
|
253 * support the concept of global object |
85a6db6624ab
Simplifying the way to obtain Language.globalObject
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22200
diff
changeset
|
254 */ |
85a6db6624ab
Simplifying the way to obtain Language.globalObject
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22200
diff
changeset
|
255 protected String globalObject() { |
85a6db6624ab
Simplifying the way to obtain Language.globalObject
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22200
diff
changeset
|
256 throw new UnsupportedOperationException("globalObject() method not implemented"); |
85a6db6624ab
Simplifying the way to obtain Language.globalObject
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22200
diff
changeset
|
257 } |
85a6db6624ab
Simplifying the way to obtain Language.globalObject
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22200
diff
changeset
|
258 |
85a6db6624ab
Simplifying the way to obtain Language.globalObject
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22200
diff
changeset
|
259 /** |
22375
78594d342228
Give Truffle languages access to evaluation functions of other languages.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22284
diff
changeset
|
260 * Name of a function to parse source written in some other language. When the function is |
78594d342228
Give Truffle languages access to evaluation functions of other languages.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22284
diff
changeset
|
261 * executed, it expects two arguments. First one is MIME type identifying |
78594d342228
Give Truffle languages access to evaluation functions of other languages.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22284
diff
changeset
|
262 * {@link TruffleLanguage} and the second one is the source code to parse in that language and |
78594d342228
Give Truffle languages access to evaluation functions of other languages.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22284
diff
changeset
|
263 * execute it. The result of the execution is then returned back to the caller. |
78594d342228
Give Truffle languages access to evaluation functions of other languages.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22284
diff
changeset
|
264 * |
78594d342228
Give Truffle languages access to evaluation functions of other languages.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22284
diff
changeset
|
265 * @return name of globally exported symbol to invoke when one wants to execute some code |
78594d342228
Give Truffle languages access to evaluation functions of other languages.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22284
diff
changeset
|
266 */ |
78594d342228
Give Truffle languages access to evaluation functions of other languages.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22284
diff
changeset
|
267 protected String evaluateSource() { |
78594d342228
Give Truffle languages access to evaluation functions of other languages.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22284
diff
changeset
|
268 throw new UnsupportedOperationException("evaluateSource() method not implemented"); |
78594d342228
Give Truffle languages access to evaluation functions of other languages.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22284
diff
changeset
|
269 } |
78594d342228
Give Truffle languages access to evaluation functions of other languages.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22284
diff
changeset
|
270 |
78594d342228
Give Truffle languages access to evaluation functions of other languages.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22284
diff
changeset
|
271 /** |
22382
fb607f23d1eb
Apply formating rules
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22381
diff
changeset
|
272 * Code snippet to multiplyCode two two variables. The test uses the snippet as a parameter to |
fb607f23d1eb
Apply formating rules
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22381
diff
changeset
|
273 * your language's |
fb607f23d1eb
Apply formating rules
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22381
diff
changeset
|
274 * {@link TruffleLanguage#parse(com.oracle.truffle.api.source.Source, com.oracle.truffle.api.nodes.Node, java.lang.String...)} |
22378
06bdf4a43126
Adding parse with argument names into the API and TCK
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22375
diff
changeset
|
275 * method. |
06bdf4a43126
Adding parse with argument names into the API and TCK
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22375
diff
changeset
|
276 * |
06bdf4a43126
Adding parse with argument names into the API and TCK
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22375
diff
changeset
|
277 * @param firstName name of the first variable to multiplyCode |
06bdf4a43126
Adding parse with argument names into the API and TCK
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22375
diff
changeset
|
278 * @param secondName name of the second variable to multiplyCode |
06bdf4a43126
Adding parse with argument names into the API and TCK
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22375
diff
changeset
|
279 * @return code snippet that multiplies the two variables in your language |
06bdf4a43126
Adding parse with argument names into the API and TCK
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22375
diff
changeset
|
280 */ |
06bdf4a43126
Adding parse with argument names into the API and TCK
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22375
diff
changeset
|
281 protected String multiplyCode(String firstName, String secondName) { |
06bdf4a43126
Adding parse with argument names into the API and TCK
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22375
diff
changeset
|
282 throw new UnsupportedOperationException("multiply(String,String) method not implemeted!"); |
06bdf4a43126
Adding parse with argument names into the API and TCK
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22375
diff
changeset
|
283 } |
06bdf4a43126
Adding parse with argument names into the API and TCK
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22375
diff
changeset
|
284 |
06bdf4a43126
Adding parse with argument names into the API and TCK
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22375
diff
changeset
|
285 /** |
22172
b31dcacfc8ff
Replacing more TruffleVM references in comments with the new PolyglotEngine name
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22170
diff
changeset
|
286 * Name of a function that counts number of its invocations in current {@link PolyglotEngine} |
22046
e7c2d36daf72
TruffleLanguage.parse method to convert a source to CallTarget. Basic caching to make sure the code is shared among tenants in one JVM.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21960
diff
changeset
|
287 * context. Your function should somehow keep a counter to remember number of its invocations |
e7c2d36daf72
TruffleLanguage.parse method to convert a source to CallTarget. Basic caching to make sure the code is shared among tenants in one JVM.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21960
diff
changeset
|
288 * and always increment it. The first invocation should return <code>1</code>, the second |
e7c2d36daf72
TruffleLanguage.parse method to convert a source to CallTarget. Basic caching to make sure the code is shared among tenants in one JVM.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21960
diff
changeset
|
289 * <code>2</code> and so on. The returned values are expected to be instances of {@link Number}. |
e7c2d36daf72
TruffleLanguage.parse method to convert a source to CallTarget. Basic caching to make sure the code is shared among tenants in one JVM.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21960
diff
changeset
|
290 * <p> |
e7c2d36daf72
TruffleLanguage.parse method to convert a source to CallTarget. Basic caching to make sure the code is shared among tenants in one JVM.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21960
diff
changeset
|
291 * The function will be used to test that two instances of your language can co-exist next to |
e7c2d36daf72
TruffleLanguage.parse method to convert a source to CallTarget. Basic caching to make sure the code is shared among tenants in one JVM.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21960
diff
changeset
|
292 * each other. Without being mutually influenced. |
e7c2d36daf72
TruffleLanguage.parse method to convert a source to CallTarget. Basic caching to make sure the code is shared among tenants in one JVM.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21960
diff
changeset
|
293 * |
e7c2d36daf72
TruffleLanguage.parse method to convert a source to CallTarget. Basic caching to make sure the code is shared among tenants in one JVM.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21960
diff
changeset
|
294 * @return name of globally expected symbol |
e7c2d36daf72
TruffleLanguage.parse method to convert a source to CallTarget. Basic caching to make sure the code is shared among tenants in one JVM.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21960
diff
changeset
|
295 */ |
e7c2d36daf72
TruffleLanguage.parse method to convert a source to CallTarget. Basic caching to make sure the code is shared among tenants in one JVM.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21960
diff
changeset
|
296 protected abstract String countInvocations(); |
e7c2d36daf72
TruffleLanguage.parse method to convert a source to CallTarget. Basic caching to make sure the code is shared among tenants in one JVM.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21960
diff
changeset
|
297 |
e7c2d36daf72
TruffleLanguage.parse method to convert a source to CallTarget. Basic caching to make sure the code is shared among tenants in one JVM.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21960
diff
changeset
|
298 /** |
21938
0a6e10379b9b
Keeping only Truffle-related modules in this repository
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
299 * Return a code snippet that is invalid in your language. Its |
22172
b31dcacfc8ff
Replacing more TruffleVM references in comments with the new PolyglotEngine name
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22170
diff
changeset
|
300 * {@link PolyglotEngine#eval(com.oracle.truffle.api.source.Source) evaluation} should fail and |
b31dcacfc8ff
Replacing more TruffleVM references in comments with the new PolyglotEngine name
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22170
diff
changeset
|
301 * yield an exception. |
21938
0a6e10379b9b
Keeping only Truffle-related modules in this repository
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
302 * |
0a6e10379b9b
Keeping only Truffle-related modules in this repository
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
303 * @return code snippet invalid in the tested language |
0a6e10379b9b
Keeping only Truffle-related modules in this repository
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
304 */ |
0a6e10379b9b
Keeping only Truffle-related modules in this repository
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
305 protected abstract String invalidCode(); |
0a6e10379b9b
Keeping only Truffle-related modules in this repository
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
306 |
22135
e70b20f4bb00
Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22121
diff
changeset
|
307 /** |
e70b20f4bb00
Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22121
diff
changeset
|
308 * Name of a function that returns a compound object with members representing certain |
e70b20f4bb00
Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22121
diff
changeset
|
309 * operations. In the JavaScript the object should look like: |
22436
46a6d3eb790c
Adopt TCK and Polyglot after changes to execute and invoke message
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22382
diff
changeset
|
310 * |
22135
e70b20f4bb00
Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22121
diff
changeset
|
311 * <pre> |
e70b20f4bb00
Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22121
diff
changeset
|
312 * <b>var</b> obj = { |
e70b20f4bb00
Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22121
diff
changeset
|
313 * 'fourtyTwo': function {@link #fourtyTwo()}, |
e70b20f4bb00
Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22121
diff
changeset
|
314 * 'plus': function {@link #plusInt()}, |
e70b20f4bb00
Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22121
diff
changeset
|
315 * 'returnsNull': function {@link #returnsNull()}, |
e70b20f4bb00
Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22121
diff
changeset
|
316 * 'returnsThis': function() { return obj; } |
e70b20f4bb00
Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22121
diff
changeset
|
317 * }; |
e70b20f4bb00
Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22121
diff
changeset
|
318 * <b>return</b> obj; |
e70b20f4bb00
Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22121
diff
changeset
|
319 * </pre> |
22436
46a6d3eb790c
Adopt TCK and Polyglot after changes to execute and invoke message
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22382
diff
changeset
|
320 * |
22135
e70b20f4bb00
Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22121
diff
changeset
|
321 * The returned object shall have three functions that will be obtained and used exactly as |
e70b20f4bb00
Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22121
diff
changeset
|
322 * described in their Javadoc - e.g. {@link #fourtyTwo()}, {@link #plusInt()} and |
e70b20f4bb00
Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22121
diff
changeset
|
323 * {@link #returnsNull()}. In addition to that there should be one more function |
e70b20f4bb00
Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22121
diff
changeset
|
324 * <b>returnsThis</b> that will return the object itself again. |
e70b20f4bb00
Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22121
diff
changeset
|
325 * |
e70b20f4bb00
Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22121
diff
changeset
|
326 * @return name of a function that returns such compound object |
e70b20f4bb00
Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22121
diff
changeset
|
327 */ |
e70b20f4bb00
Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22121
diff
changeset
|
328 protected String compoundObject() { |
22156
50056a161d7f
Replacing time out associated warnings by UnsupportedOperationException. Meaning of exception is probably more straightforward than a soft hint attempted before. Shouldn't influence the way things are build, if tests are skipped.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22142
diff
changeset
|
329 throw new UnsupportedOperationException("compoundObject() method not implemented"); |
22135
e70b20f4bb00
Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22121
diff
changeset
|
330 } |
e70b20f4bb00
Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22121
diff
changeset
|
331 |
22523
6ab540203853
Expanding TCK to cover reading and writing of object properties with various primitive types
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22496
diff
changeset
|
332 /** |
6ab540203853
Expanding TCK to cover reading and writing of object properties with various primitive types
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22496
diff
changeset
|
333 * Name of a function that returns a compound object with members representing certain primitive |
6ab540203853
Expanding TCK to cover reading and writing of object properties with various primitive types
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22496
diff
changeset
|
334 * types. In the JavaScript the object should look like: |
6ab540203853
Expanding TCK to cover reading and writing of object properties with various primitive types
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22496
diff
changeset
|
335 * |
6ab540203853
Expanding TCK to cover reading and writing of object properties with various primitive types
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22496
diff
changeset
|
336 * <pre> |
6ab540203853
Expanding TCK to cover reading and writing of object properties with various primitive types
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22496
diff
changeset
|
337 * <b>var</b> obj = { |
6ab540203853
Expanding TCK to cover reading and writing of object properties with various primitive types
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22496
diff
changeset
|
338 * 'byteValue': 0, |
6ab540203853
Expanding TCK to cover reading and writing of object properties with various primitive types
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22496
diff
changeset
|
339 * 'shortValue': 0, |
6ab540203853
Expanding TCK to cover reading and writing of object properties with various primitive types
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22496
diff
changeset
|
340 * 'intValue': 0, |
6ab540203853
Expanding TCK to cover reading and writing of object properties with various primitive types
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22496
diff
changeset
|
341 * 'longValue': 0, |
6ab540203853
Expanding TCK to cover reading and writing of object properties with various primitive types
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22496
diff
changeset
|
342 * 'floatValue': 0.0, |
6ab540203853
Expanding TCK to cover reading and writing of object properties with various primitive types
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22496
diff
changeset
|
343 * 'doubleValue': 0.0, |
6ab540203853
Expanding TCK to cover reading and writing of object properties with various primitive types
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22496
diff
changeset
|
344 * 'charValue': '0', |
6ab540203853
Expanding TCK to cover reading and writing of object properties with various primitive types
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22496
diff
changeset
|
345 * 'stringValue': '', |
6ab540203853
Expanding TCK to cover reading and writing of object properties with various primitive types
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22496
diff
changeset
|
346 * 'booleanVlaue': false |
6ab540203853
Expanding TCK to cover reading and writing of object properties with various primitive types
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22496
diff
changeset
|
347 * }; |
6ab540203853
Expanding TCK to cover reading and writing of object properties with various primitive types
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22496
diff
changeset
|
348 * <b>return</b> obj; |
6ab540203853
Expanding TCK to cover reading and writing of object properties with various primitive types
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22496
diff
changeset
|
349 * </pre> |
6ab540203853
Expanding TCK to cover reading and writing of object properties with various primitive types
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22496
diff
changeset
|
350 * |
6ab540203853
Expanding TCK to cover reading and writing of object properties with various primitive types
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22496
diff
changeset
|
351 * The returned object shall have slots for these values that can be read and written to. |
6ab540203853
Expanding TCK to cover reading and writing of object properties with various primitive types
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22496
diff
changeset
|
352 * Various test methods try to read and modify the values. Each invocation of the function |
6ab540203853
Expanding TCK to cover reading and writing of object properties with various primitive types
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22496
diff
changeset
|
353 * should yield new object. |
6ab540203853
Expanding TCK to cover reading and writing of object properties with various primitive types
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22496
diff
changeset
|
354 * |
6ab540203853
Expanding TCK to cover reading and writing of object properties with various primitive types
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22496
diff
changeset
|
355 * @return name of a function that returns such values object |
6ab540203853
Expanding TCK to cover reading and writing of object properties with various primitive types
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22496
diff
changeset
|
356 */ |
6ab540203853
Expanding TCK to cover reading and writing of object properties with various primitive types
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22496
diff
changeset
|
357 protected String valuesObject() { |
6ab540203853
Expanding TCK to cover reading and writing of object properties with various primitive types
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22496
diff
changeset
|
358 throw new UnsupportedOperationException("valuesObject() method not implemented"); |
6ab540203853
Expanding TCK to cover reading and writing of object properties with various primitive types
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22496
diff
changeset
|
359 } |
6ab540203853
Expanding TCK to cover reading and writing of object properties with various primitive types
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22496
diff
changeset
|
360 |
22542
f8fb609939a7
Give implementors of the TCK control over comparing doubles.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22525
diff
changeset
|
361 /** Assert two double values are the same. Various languages may have different |
f8fb609939a7
Give implementors of the TCK control over comparing doubles.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22525
diff
changeset
|
362 * semantics with respect to double numbers. Some of the language may not |
f8fb609939a7
Give implementors of the TCK control over comparing doubles.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22525
diff
changeset
|
363 * support <b>double</b> or <b>float</b> values at all. Those languages |
f8fb609939a7
Give implementors of the TCK control over comparing doubles.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22525
diff
changeset
|
364 * may override this method and compare the values with as much precision |
f8fb609939a7
Give implementors of the TCK control over comparing doubles.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22525
diff
changeset
|
365 * as they like. |
f8fb609939a7
Give implementors of the TCK control over comparing doubles.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22525
diff
changeset
|
366 * <p> |
f8fb609939a7
Give implementors of the TCK control over comparing doubles.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22525
diff
changeset
|
367 * Default implementation of this method calls |
f8fb609939a7
Give implementors of the TCK control over comparing doubles.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22525
diff
changeset
|
368 * {@link Assert#assertEquals(java.lang.String, double, double, double)} |
f8fb609939a7
Give implementors of the TCK control over comparing doubles.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22525
diff
changeset
|
369 * with delta <code>0.1</code>. |
f8fb609939a7
Give implementors of the TCK control over comparing doubles.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22525
diff
changeset
|
370 * |
f8fb609939a7
Give implementors of the TCK control over comparing doubles.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22525
diff
changeset
|
371 * @param msg assertion message to display in case of error |
f8fb609939a7
Give implementors of the TCK control over comparing doubles.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22525
diff
changeset
|
372 * @param expectedValue the value expected by the test |
f8fb609939a7
Give implementors of the TCK control over comparing doubles.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22525
diff
changeset
|
373 * @param actualValue the real value produced by the language |
f8fb609939a7
Give implementors of the TCK control over comparing doubles.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22525
diff
changeset
|
374 * @throws AssertionError if the values are different according to the language semantics |
f8fb609939a7
Give implementors of the TCK control over comparing doubles.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22525
diff
changeset
|
375 */ |
f8fb609939a7
Give implementors of the TCK control over comparing doubles.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22525
diff
changeset
|
376 protected void assertDouble(String msg, double expectedValue, double actualValue) { |
f8fb609939a7
Give implementors of the TCK control over comparing doubles.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22525
diff
changeset
|
377 assertEquals(msg, expectedValue, actualValue, 0.1); |
f8fb609939a7
Give implementors of the TCK control over comparing doubles.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22525
diff
changeset
|
378 } |
f8fb609939a7
Give implementors of the TCK control over comparing doubles.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22525
diff
changeset
|
379 |
22170
796f0fef110e
Renaming to PolyglotEngine
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22168
diff
changeset
|
380 private PolyglotEngine vm() throws Exception { |
21938
0a6e10379b9b
Keeping only Truffle-related modules in this repository
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
381 if (tckVM == null) { |
0a6e10379b9b
Keeping only Truffle-related modules in this repository
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
382 tckVM = prepareVM(); |
0a6e10379b9b
Keeping only Truffle-related modules in this repository
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
383 } |
0a6e10379b9b
Keeping only Truffle-related modules in this repository
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
384 return tckVM; |
0a6e10379b9b
Keeping only Truffle-related modules in this repository
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
385 } |
0a6e10379b9b
Keeping only Truffle-related modules in this repository
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
386 |
0a6e10379b9b
Keeping only Truffle-related modules in this repository
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
387 // |
0a6e10379b9b
Keeping only Truffle-related modules in this repository
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
388 // The tests |
0a6e10379b9b
Keeping only Truffle-related modules in this repository
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
389 // |
0a6e10379b9b
Keeping only Truffle-related modules in this repository
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
390 |
0a6e10379b9b
Keeping only Truffle-related modules in this repository
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
391 @Test |
0a6e10379b9b
Keeping only Truffle-related modules in this repository
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
392 public void testFortyTwo() throws Exception { |
22170
796f0fef110e
Renaming to PolyglotEngine
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22168
diff
changeset
|
393 PolyglotEngine.Value fourtyTwo = findGlobalSymbol(fourtyTwo()); |
21938
0a6e10379b9b
Keeping only Truffle-related modules in this repository
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
394 |
22436
46a6d3eb790c
Adopt TCK and Polyglot after changes to execute and invoke message
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22382
diff
changeset
|
395 Object res = fourtyTwo.execute().get(); |
21938
0a6e10379b9b
Keeping only Truffle-related modules in this repository
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
396 |
0a6e10379b9b
Keeping only Truffle-related modules in this repository
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
397 assert res instanceof Number : "should yield a number, but was: " + res; |
0a6e10379b9b
Keeping only Truffle-related modules in this repository
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
398 |
0a6e10379b9b
Keeping only Truffle-related modules in this repository
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
399 Number n = (Number) res; |
0a6e10379b9b
Keeping only Truffle-related modules in this repository
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
400 |
0a6e10379b9b
Keeping only Truffle-related modules in this repository
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
401 assert 42 == n.intValue() : "The value is 42 = " + n.intValue(); |
0a6e10379b9b
Keeping only Truffle-related modules in this repository
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
402 } |
0a6e10379b9b
Keeping only Truffle-related modules in this repository
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
403 |
0a6e10379b9b
Keeping only Truffle-related modules in this repository
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
404 @Test |
22135
e70b20f4bb00
Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22121
diff
changeset
|
405 public void testFortyTwoWithCompoundObject() throws Exception { |
22156
50056a161d7f
Replacing time out associated warnings by UnsupportedOperationException. Meaning of exception is probably more straightforward than a soft hint attempted before. Shouldn't influence the way things are build, if tests are skipped.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22142
diff
changeset
|
406 CompoundObject obj = findCompoundSymbol(); |
22135
e70b20f4bb00
Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22121
diff
changeset
|
407 if (obj == null) { |
21938
0a6e10379b9b
Keeping only Truffle-related modules in this repository
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
408 return; |
0a6e10379b9b
Keeping only Truffle-related modules in this repository
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
409 } |
22135
e70b20f4bb00
Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22121
diff
changeset
|
410 Number res = obj.fourtyTwo(); |
e70b20f4bb00
Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22121
diff
changeset
|
411 assertEquals("Should be 42", 42, res.intValue()); |
e70b20f4bb00
Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22121
diff
changeset
|
412 } |
e70b20f4bb00
Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22121
diff
changeset
|
413 |
e70b20f4bb00
Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22121
diff
changeset
|
414 @Test |
e70b20f4bb00
Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22121
diff
changeset
|
415 public void testNull() throws Exception { |
22170
796f0fef110e
Renaming to PolyglotEngine
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22168
diff
changeset
|
416 PolyglotEngine.Value retNull = findGlobalSymbol(returnsNull()); |
21938
0a6e10379b9b
Keeping only Truffle-related modules in this repository
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
417 |
22436
46a6d3eb790c
Adopt TCK and Polyglot after changes to execute and invoke message
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22382
diff
changeset
|
418 Object res = retNull.execute().get(); |
21938
0a6e10379b9b
Keeping only Truffle-related modules in this repository
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
419 |
0a6e10379b9b
Keeping only Truffle-related modules in this repository
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
420 assertNull("Should yield real Java null", res); |
0a6e10379b9b
Keeping only Truffle-related modules in this repository
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
421 } |
0a6e10379b9b
Keeping only Truffle-related modules in this repository
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
422 |
0a6e10379b9b
Keeping only Truffle-related modules in this repository
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
423 @Test |
22279
0fc995134ff3
asJavaObject can work with null value
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22278
diff
changeset
|
424 public void testNullCanBeCastToAnything() throws Exception { |
0fc995134ff3
asJavaObject can work with null value
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22278
diff
changeset
|
425 PolyglotEngine.Value retNull = findGlobalSymbol(returnsNull()); |
0fc995134ff3
asJavaObject can work with null value
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22278
diff
changeset
|
426 |
22436
46a6d3eb790c
Adopt TCK and Polyglot after changes to execute and invoke message
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22382
diff
changeset
|
427 Object res = retNull.execute().as(CompoundObject.class); |
22279
0fc995134ff3
asJavaObject can work with null value
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22278
diff
changeset
|
428 |
0fc995134ff3
asJavaObject can work with null value
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22278
diff
changeset
|
429 assertNull("Should yield real Java null", res); |
0fc995134ff3
asJavaObject can work with null value
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22278
diff
changeset
|
430 } |
0fc995134ff3
asJavaObject can work with null value
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22278
diff
changeset
|
431 |
0fc995134ff3
asJavaObject can work with null value
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22278
diff
changeset
|
432 @Test |
22135
e70b20f4bb00
Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22121
diff
changeset
|
433 public void testNullInCompoundObject() throws Exception { |
22156
50056a161d7f
Replacing time out associated warnings by UnsupportedOperationException. Meaning of exception is probably more straightforward than a soft hint attempted before. Shouldn't influence the way things are build, if tests are skipped.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22142
diff
changeset
|
434 CompoundObject obj = findCompoundSymbol(); |
22135
e70b20f4bb00
Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22121
diff
changeset
|
435 if (obj == null) { |
e70b20f4bb00
Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22121
diff
changeset
|
436 return; |
e70b20f4bb00
Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22121
diff
changeset
|
437 } |
e70b20f4bb00
Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22121
diff
changeset
|
438 Object res = obj.returnsNull(); |
e70b20f4bb00
Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22121
diff
changeset
|
439 assertNull("Should yield real Java null", res); |
e70b20f4bb00
Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22121
diff
changeset
|
440 } |
e70b20f4bb00
Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22121
diff
changeset
|
441 |
e70b20f4bb00
Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22121
diff
changeset
|
442 @Test |
21938
0a6e10379b9b
Keeping only Truffle-related modules in this repository
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
443 public void testPlusWithInts() throws Exception { |
22135
e70b20f4bb00
Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22121
diff
changeset
|
444 int a = RANDOM.nextInt(100); |
e70b20f4bb00
Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22121
diff
changeset
|
445 int b = RANDOM.nextInt(100); |
22543
0ef597d27256
Making sure the values of random input variables are printed in case of failure
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22542
diff
changeset
|
446 doPlusWithInts(a, b); |
0ef597d27256
Making sure the values of random input variables are printed in case of failure
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22542
diff
changeset
|
447 } |
21938
0a6e10379b9b
Keeping only Truffle-related modules in this repository
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
448 |
22543
0ef597d27256
Making sure the values of random input variables are printed in case of failure
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22542
diff
changeset
|
449 @Test |
0ef597d27256
Making sure the values of random input variables are printed in case of failure
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22542
diff
changeset
|
450 public void testPlusWithOneNegativeInt() throws Exception { |
0ef597d27256
Making sure the values of random input variables are printed in case of failure
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22542
diff
changeset
|
451 int a = -RANDOM.nextInt(100); |
0ef597d27256
Making sure the values of random input variables are printed in case of failure
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22542
diff
changeset
|
452 int b = RANDOM.nextInt(100); |
0ef597d27256
Making sure the values of random input variables are printed in case of failure
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22542
diff
changeset
|
453 doPlusWithInts(a, b); |
0ef597d27256
Making sure the values of random input variables are printed in case of failure
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22542
diff
changeset
|
454 } |
0ef597d27256
Making sure the values of random input variables are printed in case of failure
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22542
diff
changeset
|
455 |
0ef597d27256
Making sure the values of random input variables are printed in case of failure
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22542
diff
changeset
|
456 private void doPlusWithInts(int a, int b) throws Exception { |
22170
796f0fef110e
Renaming to PolyglotEngine
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22168
diff
changeset
|
457 PolyglotEngine.Value plus = findGlobalSymbol(plus(int.class, int.class)); |
21938
0a6e10379b9b
Keeping only Truffle-related modules in this repository
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
458 |
22436
46a6d3eb790c
Adopt TCK and Polyglot after changes to execute and invoke message
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22382
diff
changeset
|
459 Number n = plus.execute(a, b).as(Number.class); |
22135
e70b20f4bb00
Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22121
diff
changeset
|
460 assert a + b == n.intValue() : "The value is correct: (" + a + " + " + b + ") = " + n.intValue(); |
e70b20f4bb00
Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22121
diff
changeset
|
461 } |
21938
0a6e10379b9b
Keeping only Truffle-related modules in this repository
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
462 |
22135
e70b20f4bb00
Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22121
diff
changeset
|
463 @Test |
22138
a583d7ffd285
Enhancing TCK to pass in all Java number types and see whether they result in something meaningful.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22135
diff
changeset
|
464 public void testPlusWithBytes() throws Exception { |
a583d7ffd285
Enhancing TCK to pass in all Java number types and see whether they result in something meaningful.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22135
diff
changeset
|
465 int a = RANDOM.nextInt(100); |
a583d7ffd285
Enhancing TCK to pass in all Java number types and see whether they result in something meaningful.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22135
diff
changeset
|
466 int b = RANDOM.nextInt(100); |
22543
0ef597d27256
Making sure the values of random input variables are printed in case of failure
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22542
diff
changeset
|
467 doPlusWithBytes(a, b); |
0ef597d27256
Making sure the values of random input variables are printed in case of failure
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22542
diff
changeset
|
468 } |
22138
a583d7ffd285
Enhancing TCK to pass in all Java number types and see whether they result in something meaningful.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22135
diff
changeset
|
469 |
22543
0ef597d27256
Making sure the values of random input variables are printed in case of failure
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22542
diff
changeset
|
470 @Test |
0ef597d27256
Making sure the values of random input variables are printed in case of failure
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22542
diff
changeset
|
471 public void testPlusWithOneNegativeByte() throws Exception { |
0ef597d27256
Making sure the values of random input variables are printed in case of failure
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22542
diff
changeset
|
472 int a = -RANDOM.nextInt(100); |
0ef597d27256
Making sure the values of random input variables are printed in case of failure
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22542
diff
changeset
|
473 int b = RANDOM.nextInt(100); |
0ef597d27256
Making sure the values of random input variables are printed in case of failure
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22542
diff
changeset
|
474 doPlusWithBytes(a, b); |
0ef597d27256
Making sure the values of random input variables are printed in case of failure
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22542
diff
changeset
|
475 } |
0ef597d27256
Making sure the values of random input variables are printed in case of failure
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22542
diff
changeset
|
476 |
0ef597d27256
Making sure the values of random input variables are printed in case of failure
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22542
diff
changeset
|
477 private void doPlusWithBytes(int a, int b) throws Exception { |
22170
796f0fef110e
Renaming to PolyglotEngine
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22168
diff
changeset
|
478 PolyglotEngine.Value plus = findGlobalSymbol(plus(byte.class, byte.class)); |
22138
a583d7ffd285
Enhancing TCK to pass in all Java number types and see whether they result in something meaningful.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22135
diff
changeset
|
479 |
22436
46a6d3eb790c
Adopt TCK and Polyglot after changes to execute and invoke message
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22382
diff
changeset
|
480 Number n = plus.execute((byte) a, (byte) b).as(Number.class); |
22138
a583d7ffd285
Enhancing TCK to pass in all Java number types and see whether they result in something meaningful.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22135
diff
changeset
|
481 assert a + b == n.intValue() : "The value is correct: (" + a + " + " + b + ") = " + n.intValue(); |
a583d7ffd285
Enhancing TCK to pass in all Java number types and see whether they result in something meaningful.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22135
diff
changeset
|
482 } |
a583d7ffd285
Enhancing TCK to pass in all Java number types and see whether they result in something meaningful.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22135
diff
changeset
|
483 |
a583d7ffd285
Enhancing TCK to pass in all Java number types and see whether they result in something meaningful.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22135
diff
changeset
|
484 @Test |
a583d7ffd285
Enhancing TCK to pass in all Java number types and see whether they result in something meaningful.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22135
diff
changeset
|
485 public void testPlusWithShort() throws Exception { |
a583d7ffd285
Enhancing TCK to pass in all Java number types and see whether they result in something meaningful.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22135
diff
changeset
|
486 int a = RANDOM.nextInt(100); |
a583d7ffd285
Enhancing TCK to pass in all Java number types and see whether they result in something meaningful.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22135
diff
changeset
|
487 int b = RANDOM.nextInt(100); |
22543
0ef597d27256
Making sure the values of random input variables are printed in case of failure
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22542
diff
changeset
|
488 doPlusWithShorts(a, b); |
0ef597d27256
Making sure the values of random input variables are printed in case of failure
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22542
diff
changeset
|
489 } |
22138
a583d7ffd285
Enhancing TCK to pass in all Java number types and see whether they result in something meaningful.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22135
diff
changeset
|
490 |
22543
0ef597d27256
Making sure the values of random input variables are printed in case of failure
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22542
diff
changeset
|
491 @Test |
0ef597d27256
Making sure the values of random input variables are printed in case of failure
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22542
diff
changeset
|
492 public void testPlusWithOneNegativeShort() throws Exception { |
0ef597d27256
Making sure the values of random input variables are printed in case of failure
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22542
diff
changeset
|
493 int a = RANDOM.nextInt(100); |
0ef597d27256
Making sure the values of random input variables are printed in case of failure
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22542
diff
changeset
|
494 int b = -RANDOM.nextInt(100); |
0ef597d27256
Making sure the values of random input variables are printed in case of failure
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22542
diff
changeset
|
495 doPlusWithShorts(a, b); |
0ef597d27256
Making sure the values of random input variables are printed in case of failure
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22542
diff
changeset
|
496 } |
0ef597d27256
Making sure the values of random input variables are printed in case of failure
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22542
diff
changeset
|
497 |
0ef597d27256
Making sure the values of random input variables are printed in case of failure
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22542
diff
changeset
|
498 private void doPlusWithShorts(int a, int b) throws Exception { |
22170
796f0fef110e
Renaming to PolyglotEngine
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22168
diff
changeset
|
499 PolyglotEngine.Value plus = findGlobalSymbol(plus(short.class, short.class)); |
22138
a583d7ffd285
Enhancing TCK to pass in all Java number types and see whether they result in something meaningful.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22135
diff
changeset
|
500 |
22436
46a6d3eb790c
Adopt TCK and Polyglot after changes to execute and invoke message
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22382
diff
changeset
|
501 Number n = plus.execute((short) a, (short) b).as(Number.class); |
22138
a583d7ffd285
Enhancing TCK to pass in all Java number types and see whether they result in something meaningful.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22135
diff
changeset
|
502 assert a + b == n.intValue() : "The value is correct: (" + a + " + " + b + ") = " + n.intValue(); |
a583d7ffd285
Enhancing TCK to pass in all Java number types and see whether they result in something meaningful.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22135
diff
changeset
|
503 } |
a583d7ffd285
Enhancing TCK to pass in all Java number types and see whether they result in something meaningful.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22135
diff
changeset
|
504 |
a583d7ffd285
Enhancing TCK to pass in all Java number types and see whether they result in something meaningful.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22135
diff
changeset
|
505 @Test |
a583d7ffd285
Enhancing TCK to pass in all Java number types and see whether they result in something meaningful.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22135
diff
changeset
|
506 public void testPlusWithLong() throws Exception { |
a583d7ffd285
Enhancing TCK to pass in all Java number types and see whether they result in something meaningful.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22135
diff
changeset
|
507 long a = RANDOM.nextInt(100); |
a583d7ffd285
Enhancing TCK to pass in all Java number types and see whether they result in something meaningful.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22135
diff
changeset
|
508 long b = RANDOM.nextInt(100); |
22543
0ef597d27256
Making sure the values of random input variables are printed in case of failure
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22542
diff
changeset
|
509 doPlusWithLong(a, b); |
0ef597d27256
Making sure the values of random input variables are printed in case of failure
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22542
diff
changeset
|
510 } |
22138
a583d7ffd285
Enhancing TCK to pass in all Java number types and see whether they result in something meaningful.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22135
diff
changeset
|
511 |
22543
0ef597d27256
Making sure the values of random input variables are printed in case of failure
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22542
diff
changeset
|
512 @Test |
0ef597d27256
Making sure the values of random input variables are printed in case of failure
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22542
diff
changeset
|
513 public void testPlusWithLongMaxIntMinInt() throws Exception { |
0ef597d27256
Making sure the values of random input variables are printed in case of failure
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22542
diff
changeset
|
514 doPlusWithLong(Integer.MAX_VALUE, Integer.MIN_VALUE); |
0ef597d27256
Making sure the values of random input variables are printed in case of failure
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22542
diff
changeset
|
515 } |
0ef597d27256
Making sure the values of random input variables are printed in case of failure
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22542
diff
changeset
|
516 |
0ef597d27256
Making sure the values of random input variables are printed in case of failure
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22542
diff
changeset
|
517 private void doPlusWithLong(long a, long b) throws Exception { |
22170
796f0fef110e
Renaming to PolyglotEngine
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22168
diff
changeset
|
518 PolyglotEngine.Value plus = findGlobalSymbol(plus(long.class, long.class)); |
22138
a583d7ffd285
Enhancing TCK to pass in all Java number types and see whether they result in something meaningful.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22135
diff
changeset
|
519 |
22436
46a6d3eb790c
Adopt TCK and Polyglot after changes to execute and invoke message
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22382
diff
changeset
|
520 Number n = plus.execute(a, b).as(Number.class); |
22138
a583d7ffd285
Enhancing TCK to pass in all Java number types and see whether they result in something meaningful.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22135
diff
changeset
|
521 assert a + b == n.longValue() : "The value is correct: (" + a + " + " + b + ") = " + n.longValue(); |
a583d7ffd285
Enhancing TCK to pass in all Java number types and see whether they result in something meaningful.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22135
diff
changeset
|
522 } |
a583d7ffd285
Enhancing TCK to pass in all Java number types and see whether they result in something meaningful.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22135
diff
changeset
|
523 |
a583d7ffd285
Enhancing TCK to pass in all Java number types and see whether they result in something meaningful.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22135
diff
changeset
|
524 @Test |
22544
9aded7e1e122
When integer values are on input of any language, the result should be the same regardless they are stored as int or float or double
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22543
diff
changeset
|
525 public void testPlusWithDoubleFloatSameAsInt() throws Exception { |
9aded7e1e122
When integer values are on input of any language, the result should be the same regardless they are stored as int or float or double
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22543
diff
changeset
|
526 int x = RANDOM.nextInt(100); |
9aded7e1e122
When integer values are on input of any language, the result should be the same regardless they are stored as int or float or double
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22543
diff
changeset
|
527 int y = RANDOM.nextInt(100); |
9aded7e1e122
When integer values are on input of any language, the result should be the same regardless they are stored as int or float or double
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22543
diff
changeset
|
528 float a = x; |
9aded7e1e122
When integer values are on input of any language, the result should be the same regardless they are stored as int or float or double
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22543
diff
changeset
|
529 float b = y; |
9aded7e1e122
When integer values are on input of any language, the result should be the same regardless they are stored as int or float or double
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22543
diff
changeset
|
530 double u = a; |
9aded7e1e122
When integer values are on input of any language, the result should be the same regardless they are stored as int or float or double
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22543
diff
changeset
|
531 double v = b; |
9aded7e1e122
When integer values are on input of any language, the result should be the same regardless they are stored as int or float or double
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22543
diff
changeset
|
532 |
9aded7e1e122
When integer values are on input of any language, the result should be the same regardless they are stored as int or float or double
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22543
diff
changeset
|
533 PolyglotEngine.Value floatPlus = findGlobalSymbol(plus(float.class, float.class)); |
9aded7e1e122
When integer values are on input of any language, the result should be the same regardless they are stored as int or float or double
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22543
diff
changeset
|
534 PolyglotEngine.Value doublePlus = findGlobalSymbol(plus(double.class, double.class)); |
9aded7e1e122
When integer values are on input of any language, the result should be the same regardless they are stored as int or float or double
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22543
diff
changeset
|
535 PolyglotEngine.Value intPlus = findGlobalSymbol(plus(int.class, int.class)); |
9aded7e1e122
When integer values are on input of any language, the result should be the same regardless they are stored as int or float or double
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22543
diff
changeset
|
536 |
9aded7e1e122
When integer values are on input of any language, the result should be the same regardless they are stored as int or float or double
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22543
diff
changeset
|
537 Number floatResult = floatPlus.execute(a, b).as(Number.class); |
9aded7e1e122
When integer values are on input of any language, the result should be the same regardless they are stored as int or float or double
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22543
diff
changeset
|
538 Number doubleResult = doublePlus.execute(a, b).as(Number.class); |
9aded7e1e122
When integer values are on input of any language, the result should be the same regardless they are stored as int or float or double
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22543
diff
changeset
|
539 Number intResult = intPlus.execute(a, b).as(Number.class); |
9aded7e1e122
When integer values are on input of any language, the result should be the same regardless they are stored as int or float or double
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22543
diff
changeset
|
540 |
9aded7e1e122
When integer values are on input of any language, the result should be the same regardless they are stored as int or float or double
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22543
diff
changeset
|
541 assertEquals("Correct value computed via int: (" + a + " + " + b + ")", x + y, intResult.intValue()); |
9aded7e1e122
When integer values are on input of any language, the result should be the same regardless they are stored as int or float or double
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22543
diff
changeset
|
542 assertEquals("Correct value computed via float: (" + a + " + " + b + ")", intResult.intValue(), floatResult.intValue()); |
9aded7e1e122
When integer values are on input of any language, the result should be the same regardless they are stored as int or float or double
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22543
diff
changeset
|
543 assertEquals("Correct value computed via double: (" + a + " + " + b + ")", intResult.intValue(), doubleResult.intValue()); |
9aded7e1e122
When integer values are on input of any language, the result should be the same regardless they are stored as int or float or double
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22543
diff
changeset
|
544 } |
9aded7e1e122
When integer values are on input of any language, the result should be the same regardless they are stored as int or float or double
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22543
diff
changeset
|
545 |
9aded7e1e122
When integer values are on input of any language, the result should be the same regardless they are stored as int or float or double
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22543
diff
changeset
|
546 @Test |
22138
a583d7ffd285
Enhancing TCK to pass in all Java number types and see whether they result in something meaningful.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22135
diff
changeset
|
547 public void testPlusWithFloat() throws Exception { |
22542
f8fb609939a7
Give implementors of the TCK control over comparing doubles.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22525
diff
changeset
|
548 float a = RANDOM.nextFloat() * 100.0f; |
f8fb609939a7
Give implementors of the TCK control over comparing doubles.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22525
diff
changeset
|
549 float b = RANDOM.nextFloat() * 100.0f; |
22138
a583d7ffd285
Enhancing TCK to pass in all Java number types and see whether they result in something meaningful.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22135
diff
changeset
|
550 |
22543
0ef597d27256
Making sure the values of random input variables are printed in case of failure
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22542
diff
changeset
|
551 doPlusWithFloat(a, b); |
0ef597d27256
Making sure the values of random input variables are printed in case of failure
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22542
diff
changeset
|
552 } |
0ef597d27256
Making sure the values of random input variables are printed in case of failure
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22542
diff
changeset
|
553 |
0ef597d27256
Making sure the values of random input variables are printed in case of failure
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22542
diff
changeset
|
554 private void doPlusWithFloat(float a, float b) throws Exception { |
22170
796f0fef110e
Renaming to PolyglotEngine
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22168
diff
changeset
|
555 PolyglotEngine.Value plus = findGlobalSymbol(plus(float.class, float.class)); |
22138
a583d7ffd285
Enhancing TCK to pass in all Java number types and see whether they result in something meaningful.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22135
diff
changeset
|
556 |
22436
46a6d3eb790c
Adopt TCK and Polyglot after changes to execute and invoke message
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22382
diff
changeset
|
557 Number n = plus.execute(a, b).as(Number.class); |
22543
0ef597d27256
Making sure the values of random input variables are printed in case of failure
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22542
diff
changeset
|
558 assertDouble("Correct value computed: (" + a + " + " + b + ")", a + b, n.floatValue()); |
0ef597d27256
Making sure the values of random input variables are printed in case of failure
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22542
diff
changeset
|
559 } |
22138
a583d7ffd285
Enhancing TCK to pass in all Java number types and see whether they result in something meaningful.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22135
diff
changeset
|
560 |
a583d7ffd285
Enhancing TCK to pass in all Java number types and see whether they result in something meaningful.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22135
diff
changeset
|
561 @Test |
a583d7ffd285
Enhancing TCK to pass in all Java number types and see whether they result in something meaningful.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22135
diff
changeset
|
562 public void testPlusWithDouble() throws Exception { |
22542
f8fb609939a7
Give implementors of the TCK control over comparing doubles.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22525
diff
changeset
|
563 double a = RANDOM.nextDouble() * 100.0; |
f8fb609939a7
Give implementors of the TCK control over comparing doubles.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22525
diff
changeset
|
564 double b = RANDOM.nextDouble() * 100.0; |
22543
0ef597d27256
Making sure the values of random input variables are printed in case of failure
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22542
diff
changeset
|
565 doPlusWithDouble(a, b); |
0ef597d27256
Making sure the values of random input variables are printed in case of failure
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22542
diff
changeset
|
566 } |
22138
a583d7ffd285
Enhancing TCK to pass in all Java number types and see whether they result in something meaningful.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22135
diff
changeset
|
567 |
22543
0ef597d27256
Making sure the values of random input variables are printed in case of failure
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22542
diff
changeset
|
568 @Test |
0ef597d27256
Making sure the values of random input variables are printed in case of failure
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22542
diff
changeset
|
569 public void testPlusWithDoubleRound() throws Exception { |
0ef597d27256
Making sure the values of random input variables are printed in case of failure
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22542
diff
changeset
|
570 double a = RANDOM.nextInt(1000); |
0ef597d27256
Making sure the values of random input variables are printed in case of failure
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22542
diff
changeset
|
571 double b = RANDOM.nextInt(1000); |
0ef597d27256
Making sure the values of random input variables are printed in case of failure
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22542
diff
changeset
|
572 |
0ef597d27256
Making sure the values of random input variables are printed in case of failure
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22542
diff
changeset
|
573 doPlusWithDouble(a, b); |
0ef597d27256
Making sure the values of random input variables are printed in case of failure
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22542
diff
changeset
|
574 } |
0ef597d27256
Making sure the values of random input variables are printed in case of failure
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22542
diff
changeset
|
575 |
0ef597d27256
Making sure the values of random input variables are printed in case of failure
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22542
diff
changeset
|
576 @Test |
0ef597d27256
Making sure the values of random input variables are printed in case of failure
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22542
diff
changeset
|
577 public void testPlusWithDoubleMaxInt() throws Exception { |
0ef597d27256
Making sure the values of random input variables are printed in case of failure
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22542
diff
changeset
|
578 double a = Integer.MAX_VALUE; |
0ef597d27256
Making sure the values of random input variables are printed in case of failure
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22542
diff
changeset
|
579 double b = 1; |
0ef597d27256
Making sure the values of random input variables are printed in case of failure
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22542
diff
changeset
|
580 |
0ef597d27256
Making sure the values of random input variables are printed in case of failure
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22542
diff
changeset
|
581 doPlusWithDouble(a, b); |
0ef597d27256
Making sure the values of random input variables are printed in case of failure
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22542
diff
changeset
|
582 } |
0ef597d27256
Making sure the values of random input variables are printed in case of failure
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22542
diff
changeset
|
583 |
0ef597d27256
Making sure the values of random input variables are printed in case of failure
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22542
diff
changeset
|
584 private void doPlusWithDouble(double a, double b) throws Exception { |
0ef597d27256
Making sure the values of random input variables are printed in case of failure
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22542
diff
changeset
|
585 PolyglotEngine.Value plus = findGlobalSymbol(plus(double.class, double.class)); |
22138
a583d7ffd285
Enhancing TCK to pass in all Java number types and see whether they result in something meaningful.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22135
diff
changeset
|
586 |
22436
46a6d3eb790c
Adopt TCK and Polyglot after changes to execute and invoke message
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22382
diff
changeset
|
587 Number n = plus.execute(a, b).as(Number.class); |
22543
0ef597d27256
Making sure the values of random input variables are printed in case of failure
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22542
diff
changeset
|
588 assertDouble("Correct value computed: (" + a + " + " + b + ")", a + b, n.doubleValue()); |
22138
a583d7ffd285
Enhancing TCK to pass in all Java number types and see whether they result in something meaningful.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22135
diff
changeset
|
589 } |
a583d7ffd285
Enhancing TCK to pass in all Java number types and see whether they result in something meaningful.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22135
diff
changeset
|
590 |
a583d7ffd285
Enhancing TCK to pass in all Java number types and see whether they result in something meaningful.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22135
diff
changeset
|
591 @Test |
22135
e70b20f4bb00
Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22121
diff
changeset
|
592 public void testPlusWithIntsOnCompoundObject() throws Exception { |
e70b20f4bb00
Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22121
diff
changeset
|
593 int a = RANDOM.nextInt(100); |
e70b20f4bb00
Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22121
diff
changeset
|
594 int b = RANDOM.nextInt(100); |
21938
0a6e10379b9b
Keeping only Truffle-related modules in this repository
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
595 |
22156
50056a161d7f
Replacing time out associated warnings by UnsupportedOperationException. Meaning of exception is probably more straightforward than a soft hint attempted before. Shouldn't influence the way things are build, if tests are skipped.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22142
diff
changeset
|
596 CompoundObject obj = findCompoundSymbol(); |
22135
e70b20f4bb00
Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22121
diff
changeset
|
597 if (obj == null) { |
e70b20f4bb00
Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22121
diff
changeset
|
598 return; |
e70b20f4bb00
Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22121
diff
changeset
|
599 } |
21938
0a6e10379b9b
Keeping only Truffle-related modules in this repository
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
600 |
22135
e70b20f4bb00
Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22121
diff
changeset
|
601 Number n = obj.plus(a, b); |
21938
0a6e10379b9b
Keeping only Truffle-related modules in this repository
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
602 assert a + b == n.intValue() : "The value is correct: (" + a + " + " + b + ") = " + n.intValue(); |
0a6e10379b9b
Keeping only Truffle-related modules in this repository
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
603 } |
0a6e10379b9b
Keeping only Truffle-related modules in this repository
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
604 |
0a6e10379b9b
Keeping only Truffle-related modules in this repository
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
605 @Test(expected = IOException.class) |
0a6e10379b9b
Keeping only Truffle-related modules in this repository
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
606 public void testInvalidTestMethod() throws Exception { |
0a6e10379b9b
Keeping only Truffle-related modules in this repository
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
607 String mime = mimeType(); |
0a6e10379b9b
Keeping only Truffle-related modules in this repository
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
608 String code = invalidCode(); |
22121
d045a505c2b3
Asynchronous TruffleVM can be created by providing own Executor when configuring the TruffleVM.Builder
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22104
diff
changeset
|
609 Object ret = vm().eval(Source.fromText(code, "Invalid code").withMimeType(mime)).get(); |
21938
0a6e10379b9b
Keeping only Truffle-related modules in this repository
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
610 fail("Should yield IOException, but returned " + ret); |
0a6e10379b9b
Keeping only Truffle-related modules in this repository
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
611 } |
0a6e10379b9b
Keeping only Truffle-related modules in this repository
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
612 |
21960
a88981c5ce8b
Initial test for Java Interop: Perform callback to Math.min and Math.max via TruffleObject and Message.createExecute(2).
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21951
diff
changeset
|
613 @Test |
a88981c5ce8b
Initial test for Java Interop: Perform callback to Math.min and Math.max via TruffleObject and Message.createExecute(2).
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21951
diff
changeset
|
614 public void testMaxOrMinValue() throws Exception { |
22170
796f0fef110e
Renaming to PolyglotEngine
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22168
diff
changeset
|
615 PolyglotEngine.Value apply = findGlobalSymbol(applyNumbers()); |
21960
a88981c5ce8b
Initial test for Java Interop: Perform callback to Math.min and Math.max via TruffleObject and Message.createExecute(2).
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21951
diff
changeset
|
616 |
22135
e70b20f4bb00
Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22121
diff
changeset
|
617 TruffleObject fn = JavaInterop.asTruffleFunction(LongBinaryOperation.class, new MaxMinObject(true)); |
22436
46a6d3eb790c
Adopt TCK and Polyglot after changes to execute and invoke message
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22382
diff
changeset
|
618 Object res = apply.execute(fn).get(); |
21960
a88981c5ce8b
Initial test for Java Interop: Perform callback to Math.min and Math.max via TruffleObject and Message.createExecute(2).
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21951
diff
changeset
|
619 |
a88981c5ce8b
Initial test for Java Interop: Perform callback to Math.min and Math.max via TruffleObject and Message.createExecute(2).
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21951
diff
changeset
|
620 assert res instanceof Number : "result should be a number: " + res; |
a88981c5ce8b
Initial test for Java Interop: Perform callback to Math.min and Math.max via TruffleObject and Message.createExecute(2).
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21951
diff
changeset
|
621 |
a88981c5ce8b
Initial test for Java Interop: Perform callback to Math.min and Math.max via TruffleObject and Message.createExecute(2).
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21951
diff
changeset
|
622 Number n = (Number) res; |
a88981c5ce8b
Initial test for Java Interop: Perform callback to Math.min and Math.max via TruffleObject and Message.createExecute(2).
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21951
diff
changeset
|
623 |
a88981c5ce8b
Initial test for Java Interop: Perform callback to Math.min and Math.max via TruffleObject and Message.createExecute(2).
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21951
diff
changeset
|
624 assert 42 == n.intValue() : "32 > 18 and plus 10"; |
a88981c5ce8b
Initial test for Java Interop: Perform callback to Math.min and Math.max via TruffleObject and Message.createExecute(2).
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21951
diff
changeset
|
625 } |
a88981c5ce8b
Initial test for Java Interop: Perform callback to Math.min and Math.max via TruffleObject and Message.createExecute(2).
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21951
diff
changeset
|
626 |
a88981c5ce8b
Initial test for Java Interop: Perform callback to Math.min and Math.max via TruffleObject and Message.createExecute(2).
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21951
diff
changeset
|
627 @Test |
a88981c5ce8b
Initial test for Java Interop: Perform callback to Math.min and Math.max via TruffleObject and Message.createExecute(2).
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21951
diff
changeset
|
628 public void testMaxOrMinValue2() throws Exception { |
22170
796f0fef110e
Renaming to PolyglotEngine
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22168
diff
changeset
|
629 PolyglotEngine.Value apply = findGlobalSymbol(applyNumbers()); |
21960
a88981c5ce8b
Initial test for Java Interop: Perform callback to Math.min and Math.max via TruffleObject and Message.createExecute(2).
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21951
diff
changeset
|
630 |
22135
e70b20f4bb00
Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22121
diff
changeset
|
631 TruffleObject fn = JavaInterop.asTruffleFunction(LongBinaryOperation.class, new MaxMinObject(false)); |
22436
46a6d3eb790c
Adopt TCK and Polyglot after changes to execute and invoke message
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22382
diff
changeset
|
632 final PolyglotEngine.Value result = apply.execute(fn); |
21960
a88981c5ce8b
Initial test for Java Interop: Perform callback to Math.min and Math.max via TruffleObject and Message.createExecute(2).
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21951
diff
changeset
|
633 |
22135
e70b20f4bb00
Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22121
diff
changeset
|
634 try { |
22284
33d49924a921
PolyglotEngine.Value.as(String.class) gives the language that produced the value a chance to do its conversion to appropriate textual representation.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22279
diff
changeset
|
635 Boolean res = result.as(Boolean.class); |
33d49924a921
PolyglotEngine.Value.as(String.class) gives the language that produced the value a chance to do its conversion to appropriate textual representation.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22279
diff
changeset
|
636 fail("Cannot be converted to Boolean: " + res); |
22135
e70b20f4bb00
Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22121
diff
changeset
|
637 } catch (ClassCastException ex) { |
e70b20f4bb00
Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22121
diff
changeset
|
638 // correct |
e70b20f4bb00
Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22121
diff
changeset
|
639 } |
21960
a88981c5ce8b
Initial test for Java Interop: Perform callback to Math.min and Math.max via TruffleObject and Message.createExecute(2).
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21951
diff
changeset
|
640 |
22135
e70b20f4bb00
Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22121
diff
changeset
|
641 Number n = result.as(Number.class); |
21960
a88981c5ce8b
Initial test for Java Interop: Perform callback to Math.min and Math.max via TruffleObject and Message.createExecute(2).
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21951
diff
changeset
|
642 assert 28 == n.intValue() : "18 < 32 and plus 10"; |
a88981c5ce8b
Initial test for Java Interop: Perform callback to Math.min and Math.max via TruffleObject and Message.createExecute(2).
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21951
diff
changeset
|
643 } |
a88981c5ce8b
Initial test for Java Interop: Perform callback to Math.min and Math.max via TruffleObject and Message.createExecute(2).
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21951
diff
changeset
|
644 |
22046
e7c2d36daf72
TruffleLanguage.parse method to convert a source to CallTarget. Basic caching to make sure the code is shared among tenants in one JVM.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21960
diff
changeset
|
645 @Test |
22139
597953a8e6f0
Testing behavior of primitive types returned from an interop method.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22138
diff
changeset
|
646 public void testPrimitiveReturnTypeByte() throws Exception { |
22170
796f0fef110e
Renaming to PolyglotEngine
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22168
diff
changeset
|
647 PolyglotEngine.Value apply = findGlobalSymbol(applyNumbers()); |
22139
597953a8e6f0
Testing behavior of primitive types returned from an interop method.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22138
diff
changeset
|
648 |
597953a8e6f0
Testing behavior of primitive types returned from an interop method.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22138
diff
changeset
|
649 byte value = (byte) RANDOM.nextInt(100); |
597953a8e6f0
Testing behavior of primitive types returned from an interop method.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22138
diff
changeset
|
650 |
597953a8e6f0
Testing behavior of primitive types returned from an interop method.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22138
diff
changeset
|
651 TruffleObject fn = JavaInterop.asTruffleFunction(ObjectBinaryOperation.class, new ConstantFunction(value)); |
22436
46a6d3eb790c
Adopt TCK and Polyglot after changes to execute and invoke message
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22382
diff
changeset
|
652 Number n = apply.execute(fn).as(Number.class); |
22543
0ef597d27256
Making sure the values of random input variables are printed in case of failure
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22542
diff
changeset
|
653 assertEquals("The same value returned (" + value + " + 10): ", value + 10, n.byteValue()); |
22139
597953a8e6f0
Testing behavior of primitive types returned from an interop method.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22138
diff
changeset
|
654 } |
597953a8e6f0
Testing behavior of primitive types returned from an interop method.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22138
diff
changeset
|
655 |
597953a8e6f0
Testing behavior of primitive types returned from an interop method.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22138
diff
changeset
|
656 @Test |
597953a8e6f0
Testing behavior of primitive types returned from an interop method.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22138
diff
changeset
|
657 public void testPrimitiveReturnTypeShort() throws Exception { |
22170
796f0fef110e
Renaming to PolyglotEngine
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22168
diff
changeset
|
658 PolyglotEngine.Value apply = findGlobalSymbol(applyNumbers()); |
22139
597953a8e6f0
Testing behavior of primitive types returned from an interop method.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22138
diff
changeset
|
659 |
597953a8e6f0
Testing behavior of primitive types returned from an interop method.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22138
diff
changeset
|
660 short value = (short) RANDOM.nextInt(100); |
597953a8e6f0
Testing behavior of primitive types returned from an interop method.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22138
diff
changeset
|
661 |
597953a8e6f0
Testing behavior of primitive types returned from an interop method.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22138
diff
changeset
|
662 TruffleObject fn = JavaInterop.asTruffleFunction(ObjectBinaryOperation.class, new ConstantFunction(value)); |
22436
46a6d3eb790c
Adopt TCK and Polyglot after changes to execute and invoke message
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22382
diff
changeset
|
663 Number n = apply.execute(fn).as(Number.class); |
22543
0ef597d27256
Making sure the values of random input variables are printed in case of failure
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22542
diff
changeset
|
664 assertEquals("The same value returned (" + value + " + 10): ", value + 10, n.shortValue()); |
22139
597953a8e6f0
Testing behavior of primitive types returned from an interop method.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22138
diff
changeset
|
665 } |
597953a8e6f0
Testing behavior of primitive types returned from an interop method.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22138
diff
changeset
|
666 |
597953a8e6f0
Testing behavior of primitive types returned from an interop method.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22138
diff
changeset
|
667 @Test |
597953a8e6f0
Testing behavior of primitive types returned from an interop method.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22138
diff
changeset
|
668 public void testPrimitiveReturnTypeInt() throws Exception { |
22170
796f0fef110e
Renaming to PolyglotEngine
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22168
diff
changeset
|
669 PolyglotEngine.Value apply = findGlobalSymbol(applyNumbers()); |
22139
597953a8e6f0
Testing behavior of primitive types returned from an interop method.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22138
diff
changeset
|
670 |
597953a8e6f0
Testing behavior of primitive types returned from an interop method.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22138
diff
changeset
|
671 int value = RANDOM.nextInt(100); |
597953a8e6f0
Testing behavior of primitive types returned from an interop method.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22138
diff
changeset
|
672 |
597953a8e6f0
Testing behavior of primitive types returned from an interop method.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22138
diff
changeset
|
673 TruffleObject fn = JavaInterop.asTruffleFunction(ObjectBinaryOperation.class, new ConstantFunction(value)); |
22436
46a6d3eb790c
Adopt TCK and Polyglot after changes to execute and invoke message
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22382
diff
changeset
|
674 Number n = apply.execute(fn).as(Number.class); |
22543
0ef597d27256
Making sure the values of random input variables are printed in case of failure
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22542
diff
changeset
|
675 assertEquals("The same value returned (" + value + " + 10): ", value + 10, n.intValue()); |
22139
597953a8e6f0
Testing behavior of primitive types returned from an interop method.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22138
diff
changeset
|
676 } |
597953a8e6f0
Testing behavior of primitive types returned from an interop method.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22138
diff
changeset
|
677 |
597953a8e6f0
Testing behavior of primitive types returned from an interop method.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22138
diff
changeset
|
678 @Test |
597953a8e6f0
Testing behavior of primitive types returned from an interop method.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22138
diff
changeset
|
679 public void testPrimitiveReturnTypeLong() throws Exception { |
22170
796f0fef110e
Renaming to PolyglotEngine
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22168
diff
changeset
|
680 PolyglotEngine.Value apply = findGlobalSymbol(applyNumbers()); |
22139
597953a8e6f0
Testing behavior of primitive types returned from an interop method.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22138
diff
changeset
|
681 |
597953a8e6f0
Testing behavior of primitive types returned from an interop method.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22138
diff
changeset
|
682 long value = RANDOM.nextInt(1000); |
597953a8e6f0
Testing behavior of primitive types returned from an interop method.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22138
diff
changeset
|
683 |
597953a8e6f0
Testing behavior of primitive types returned from an interop method.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22138
diff
changeset
|
684 TruffleObject fn = JavaInterop.asTruffleFunction(ObjectBinaryOperation.class, new ConstantFunction(value)); |
22436
46a6d3eb790c
Adopt TCK and Polyglot after changes to execute and invoke message
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22382
diff
changeset
|
685 Number n = apply.execute(fn).as(Number.class); |
22543
0ef597d27256
Making sure the values of random input variables are printed in case of failure
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22542
diff
changeset
|
686 assertEquals("The same value returned (" + value + " + 10): ", value + 10, n.longValue()); |
22139
597953a8e6f0
Testing behavior of primitive types returned from an interop method.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22138
diff
changeset
|
687 } |
597953a8e6f0
Testing behavior of primitive types returned from an interop method.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22138
diff
changeset
|
688 |
597953a8e6f0
Testing behavior of primitive types returned from an interop method.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22138
diff
changeset
|
689 @Test |
597953a8e6f0
Testing behavior of primitive types returned from an interop method.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22138
diff
changeset
|
690 public void testPrimitiveReturnTypeFloat() throws Exception { |
22170
796f0fef110e
Renaming to PolyglotEngine
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22168
diff
changeset
|
691 PolyglotEngine.Value apply = findGlobalSymbol(applyNumbers()); |
22139
597953a8e6f0
Testing behavior of primitive types returned from an interop method.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22138
diff
changeset
|
692 |
597953a8e6f0
Testing behavior of primitive types returned from an interop method.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22138
diff
changeset
|
693 float value = RANDOM.nextInt(1000) + RANDOM.nextFloat(); |
597953a8e6f0
Testing behavior of primitive types returned from an interop method.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22138
diff
changeset
|
694 |
597953a8e6f0
Testing behavior of primitive types returned from an interop method.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22138
diff
changeset
|
695 TruffleObject fn = JavaInterop.asTruffleFunction(ObjectBinaryOperation.class, new ConstantFunction(value)); |
22436
46a6d3eb790c
Adopt TCK and Polyglot after changes to execute and invoke message
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22382
diff
changeset
|
696 Number n = apply.execute(fn).as(Number.class); |
22543
0ef597d27256
Making sure the values of random input variables are printed in case of failure
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22542
diff
changeset
|
697 assertDouble("The same value returned (" + value + " + 10): ", value + 10, n.floatValue()); |
22139
597953a8e6f0
Testing behavior of primitive types returned from an interop method.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22138
diff
changeset
|
698 } |
597953a8e6f0
Testing behavior of primitive types returned from an interop method.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22138
diff
changeset
|
699 |
597953a8e6f0
Testing behavior of primitive types returned from an interop method.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22138
diff
changeset
|
700 @Test |
597953a8e6f0
Testing behavior of primitive types returned from an interop method.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22138
diff
changeset
|
701 public void testPrimitiveReturnTypeDouble() throws Exception { |
22170
796f0fef110e
Renaming to PolyglotEngine
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22168
diff
changeset
|
702 PolyglotEngine.Value apply = findGlobalSymbol(applyNumbers()); |
22139
597953a8e6f0
Testing behavior of primitive types returned from an interop method.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22138
diff
changeset
|
703 |
597953a8e6f0
Testing behavior of primitive types returned from an interop method.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22138
diff
changeset
|
704 double value = RANDOM.nextInt(1000) + RANDOM.nextDouble(); |
597953a8e6f0
Testing behavior of primitive types returned from an interop method.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22138
diff
changeset
|
705 |
597953a8e6f0
Testing behavior of primitive types returned from an interop method.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22138
diff
changeset
|
706 TruffleObject fn = JavaInterop.asTruffleFunction(ObjectBinaryOperation.class, new ConstantFunction(value)); |
22436
46a6d3eb790c
Adopt TCK and Polyglot after changes to execute and invoke message
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22382
diff
changeset
|
707 Number n = apply.execute(fn).as(Number.class); |
22543
0ef597d27256
Making sure the values of random input variables are printed in case of failure
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22542
diff
changeset
|
708 assertDouble("The same value returned (" + value + " + 10): ", value + 10, n.doubleValue()); |
22139
597953a8e6f0
Testing behavior of primitive types returned from an interop method.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22138
diff
changeset
|
709 } |
597953a8e6f0
Testing behavior of primitive types returned from an interop method.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22138
diff
changeset
|
710 |
597953a8e6f0
Testing behavior of primitive types returned from an interop method.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22138
diff
changeset
|
711 @Test |
22140
92906003d607
Adding check of behavior of identity function into the TCK
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22139
diff
changeset
|
712 public void testPrimitiveidentityByte() throws Exception { |
92906003d607
Adding check of behavior of identity function into the TCK
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22139
diff
changeset
|
713 String id = identity(); |
92906003d607
Adding check of behavior of identity function into the TCK
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22139
diff
changeset
|
714 if (id == null) { |
92906003d607
Adding check of behavior of identity function into the TCK
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22139
diff
changeset
|
715 return; |
92906003d607
Adding check of behavior of identity function into the TCK
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22139
diff
changeset
|
716 } |
22170
796f0fef110e
Renaming to PolyglotEngine
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22168
diff
changeset
|
717 PolyglotEngine.Value apply = findGlobalSymbol(id); |
22140
92906003d607
Adding check of behavior of identity function into the TCK
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22139
diff
changeset
|
718 |
92906003d607
Adding check of behavior of identity function into the TCK
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22139
diff
changeset
|
719 byte value = (byte) RANDOM.nextInt(100); |
92906003d607
Adding check of behavior of identity function into the TCK
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22139
diff
changeset
|
720 |
22436
46a6d3eb790c
Adopt TCK and Polyglot after changes to execute and invoke message
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22382
diff
changeset
|
721 Number n = (Number) apply.execute(value).get(); |
22140
92906003d607
Adding check of behavior of identity function into the TCK
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22139
diff
changeset
|
722 assertEquals("The same value returned", value, n.byteValue()); |
92906003d607
Adding check of behavior of identity function into the TCK
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22139
diff
changeset
|
723 } |
92906003d607
Adding check of behavior of identity function into the TCK
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22139
diff
changeset
|
724 |
92906003d607
Adding check of behavior of identity function into the TCK
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22139
diff
changeset
|
725 @Test |
22423
70a10a9f28ad
Verify that primitive data (numbers as well as String) can be passed into a language as boxed TruffleObject instances
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22422
diff
changeset
|
726 public void testPrimitiveidentityBoxedByte() throws Exception { |
70a10a9f28ad
Verify that primitive data (numbers as well as String) can be passed into a language as boxed TruffleObject instances
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22422
diff
changeset
|
727 String id = identity(); |
70a10a9f28ad
Verify that primitive data (numbers as well as String) can be passed into a language as boxed TruffleObject instances
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22422
diff
changeset
|
728 if (id == null) { |
70a10a9f28ad
Verify that primitive data (numbers as well as String) can be passed into a language as boxed TruffleObject instances
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22422
diff
changeset
|
729 return; |
70a10a9f28ad
Verify that primitive data (numbers as well as String) can be passed into a language as boxed TruffleObject instances
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22422
diff
changeset
|
730 } |
70a10a9f28ad
Verify that primitive data (numbers as well as String) can be passed into a language as boxed TruffleObject instances
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22422
diff
changeset
|
731 PolyglotEngine.Value apply = findGlobalSymbol(id); |
70a10a9f28ad
Verify that primitive data (numbers as well as String) can be passed into a language as boxed TruffleObject instances
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22422
diff
changeset
|
732 |
70a10a9f28ad
Verify that primitive data (numbers as well as String) can be passed into a language as boxed TruffleObject instances
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22422
diff
changeset
|
733 byte value = (byte) RANDOM.nextInt(100); |
70a10a9f28ad
Verify that primitive data (numbers as well as String) can be passed into a language as boxed TruffleObject instances
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22422
diff
changeset
|
734 BoxedValue boxed = new BoxedValue(value); |
70a10a9f28ad
Verify that primitive data (numbers as well as String) can be passed into a language as boxed TruffleObject instances
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22422
diff
changeset
|
735 |
22436
46a6d3eb790c
Adopt TCK and Polyglot after changes to execute and invoke message
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22382
diff
changeset
|
736 Number n = (Number) apply.execute(boxed).get(); |
22423
70a10a9f28ad
Verify that primitive data (numbers as well as String) can be passed into a language as boxed TruffleObject instances
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22422
diff
changeset
|
737 assertEquals("The same value returned", value, n.byteValue()); |
70a10a9f28ad
Verify that primitive data (numbers as well as String) can be passed into a language as boxed TruffleObject instances
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22422
diff
changeset
|
738 } |
70a10a9f28ad
Verify that primitive data (numbers as well as String) can be passed into a language as boxed TruffleObject instances
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22422
diff
changeset
|
739 |
70a10a9f28ad
Verify that primitive data (numbers as well as String) can be passed into a language as boxed TruffleObject instances
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22422
diff
changeset
|
740 @Test |
22140
92906003d607
Adding check of behavior of identity function into the TCK
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22139
diff
changeset
|
741 public void testPrimitiveidentityShort() throws Exception { |
92906003d607
Adding check of behavior of identity function into the TCK
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22139
diff
changeset
|
742 String id = identity(); |
92906003d607
Adding check of behavior of identity function into the TCK
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22139
diff
changeset
|
743 if (id == null) { |
92906003d607
Adding check of behavior of identity function into the TCK
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22139
diff
changeset
|
744 return; |
92906003d607
Adding check of behavior of identity function into the TCK
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22139
diff
changeset
|
745 } |
22170
796f0fef110e
Renaming to PolyglotEngine
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22168
diff
changeset
|
746 PolyglotEngine.Value apply = findGlobalSymbol(id); |
22140
92906003d607
Adding check of behavior of identity function into the TCK
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22139
diff
changeset
|
747 |
92906003d607
Adding check of behavior of identity function into the TCK
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22139
diff
changeset
|
748 short value = (short) RANDOM.nextInt(100); |
22436
46a6d3eb790c
Adopt TCK and Polyglot after changes to execute and invoke message
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22382
diff
changeset
|
749 Number n = (Number) apply.execute(value).get(); |
22140
92906003d607
Adding check of behavior of identity function into the TCK
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22139
diff
changeset
|
750 assertEquals("The same value returned", value, n.shortValue()); |
92906003d607
Adding check of behavior of identity function into the TCK
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22139
diff
changeset
|
751 } |
92906003d607
Adding check of behavior of identity function into the TCK
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22139
diff
changeset
|
752 |
92906003d607
Adding check of behavior of identity function into the TCK
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22139
diff
changeset
|
753 @Test |
22423
70a10a9f28ad
Verify that primitive data (numbers as well as String) can be passed into a language as boxed TruffleObject instances
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22422
diff
changeset
|
754 public void testPrimitiveidentityBoxedShort() throws Exception { |
70a10a9f28ad
Verify that primitive data (numbers as well as String) can be passed into a language as boxed TruffleObject instances
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22422
diff
changeset
|
755 String id = identity(); |
70a10a9f28ad
Verify that primitive data (numbers as well as String) can be passed into a language as boxed TruffleObject instances
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22422
diff
changeset
|
756 if (id == null) { |
70a10a9f28ad
Verify that primitive data (numbers as well as String) can be passed into a language as boxed TruffleObject instances
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22422
diff
changeset
|
757 return; |
70a10a9f28ad
Verify that primitive data (numbers as well as String) can be passed into a language as boxed TruffleObject instances
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22422
diff
changeset
|
758 } |
70a10a9f28ad
Verify that primitive data (numbers as well as String) can be passed into a language as boxed TruffleObject instances
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22422
diff
changeset
|
759 PolyglotEngine.Value apply = findGlobalSymbol(id); |
70a10a9f28ad
Verify that primitive data (numbers as well as String) can be passed into a language as boxed TruffleObject instances
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22422
diff
changeset
|
760 |
70a10a9f28ad
Verify that primitive data (numbers as well as String) can be passed into a language as boxed TruffleObject instances
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22422
diff
changeset
|
761 short value = (short) RANDOM.nextInt(100); |
70a10a9f28ad
Verify that primitive data (numbers as well as String) can be passed into a language as boxed TruffleObject instances
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22422
diff
changeset
|
762 BoxedValue boxed = new BoxedValue(value); |
70a10a9f28ad
Verify that primitive data (numbers as well as String) can be passed into a language as boxed TruffleObject instances
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22422
diff
changeset
|
763 |
22436
46a6d3eb790c
Adopt TCK and Polyglot after changes to execute and invoke message
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22382
diff
changeset
|
764 Number n = (Number) apply.execute(boxed).get(); |
22423
70a10a9f28ad
Verify that primitive data (numbers as well as String) can be passed into a language as boxed TruffleObject instances
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22422
diff
changeset
|
765 assertEquals("The same value returned", value, n.shortValue()); |
70a10a9f28ad
Verify that primitive data (numbers as well as String) can be passed into a language as boxed TruffleObject instances
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22422
diff
changeset
|
766 } |
70a10a9f28ad
Verify that primitive data (numbers as well as String) can be passed into a language as boxed TruffleObject instances
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22422
diff
changeset
|
767 |
70a10a9f28ad
Verify that primitive data (numbers as well as String) can be passed into a language as boxed TruffleObject instances
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22422
diff
changeset
|
768 @Test |
22140
92906003d607
Adding check of behavior of identity function into the TCK
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22139
diff
changeset
|
769 public void testPrimitiveidentityInt() throws Exception { |
92906003d607
Adding check of behavior of identity function into the TCK
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22139
diff
changeset
|
770 String id = identity(); |
92906003d607
Adding check of behavior of identity function into the TCK
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22139
diff
changeset
|
771 if (id == null) { |
92906003d607
Adding check of behavior of identity function into the TCK
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22139
diff
changeset
|
772 return; |
92906003d607
Adding check of behavior of identity function into the TCK
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22139
diff
changeset
|
773 } |
22170
796f0fef110e
Renaming to PolyglotEngine
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22168
diff
changeset
|
774 PolyglotEngine.Value apply = findGlobalSymbol(id); |
22140
92906003d607
Adding check of behavior of identity function into the TCK
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22139
diff
changeset
|
775 |
92906003d607
Adding check of behavior of identity function into the TCK
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22139
diff
changeset
|
776 int value = RANDOM.nextInt(100); |
92906003d607
Adding check of behavior of identity function into the TCK
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22139
diff
changeset
|
777 |
22436
46a6d3eb790c
Adopt TCK and Polyglot after changes to execute and invoke message
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22382
diff
changeset
|
778 Number n = (Number) apply.execute(value).get(); |
22140
92906003d607
Adding check of behavior of identity function into the TCK
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22139
diff
changeset
|
779 assertEquals("The same value returned", value, n.intValue()); |
92906003d607
Adding check of behavior of identity function into the TCK
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22139
diff
changeset
|
780 } |
92906003d607
Adding check of behavior of identity function into the TCK
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22139
diff
changeset
|
781 |
92906003d607
Adding check of behavior of identity function into the TCK
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22139
diff
changeset
|
782 @Test |
22423
70a10a9f28ad
Verify that primitive data (numbers as well as String) can be passed into a language as boxed TruffleObject instances
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22422
diff
changeset
|
783 public void testPrimitiveidentityBoxedInt() throws Exception { |
70a10a9f28ad
Verify that primitive data (numbers as well as String) can be passed into a language as boxed TruffleObject instances
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22422
diff
changeset
|
784 String id = identity(); |
70a10a9f28ad
Verify that primitive data (numbers as well as String) can be passed into a language as boxed TruffleObject instances
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22422
diff
changeset
|
785 if (id == null) { |
70a10a9f28ad
Verify that primitive data (numbers as well as String) can be passed into a language as boxed TruffleObject instances
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22422
diff
changeset
|
786 return; |
70a10a9f28ad
Verify that primitive data (numbers as well as String) can be passed into a language as boxed TruffleObject instances
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22422
diff
changeset
|
787 } |
70a10a9f28ad
Verify that primitive data (numbers as well as String) can be passed into a language as boxed TruffleObject instances
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22422
diff
changeset
|
788 PolyglotEngine.Value apply = findGlobalSymbol(id); |
70a10a9f28ad
Verify that primitive data (numbers as well as String) can be passed into a language as boxed TruffleObject instances
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22422
diff
changeset
|
789 |
70a10a9f28ad
Verify that primitive data (numbers as well as String) can be passed into a language as boxed TruffleObject instances
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22422
diff
changeset
|
790 int value = RANDOM.nextInt(100); |
70a10a9f28ad
Verify that primitive data (numbers as well as String) can be passed into a language as boxed TruffleObject instances
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22422
diff
changeset
|
791 BoxedValue boxed = new BoxedValue(value); |
70a10a9f28ad
Verify that primitive data (numbers as well as String) can be passed into a language as boxed TruffleObject instances
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22422
diff
changeset
|
792 |
22436
46a6d3eb790c
Adopt TCK and Polyglot after changes to execute and invoke message
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22382
diff
changeset
|
793 Number n = (Number) apply.execute(boxed).get(); |
22423
70a10a9f28ad
Verify that primitive data (numbers as well as String) can be passed into a language as boxed TruffleObject instances
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22422
diff
changeset
|
794 assertEquals("The same value returned", value, n.intValue()); |
70a10a9f28ad
Verify that primitive data (numbers as well as String) can be passed into a language as boxed TruffleObject instances
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22422
diff
changeset
|
795 } |
70a10a9f28ad
Verify that primitive data (numbers as well as String) can be passed into a language as boxed TruffleObject instances
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22422
diff
changeset
|
796 |
70a10a9f28ad
Verify that primitive data (numbers as well as String) can be passed into a language as boxed TruffleObject instances
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22422
diff
changeset
|
797 @Test |
22140
92906003d607
Adding check of behavior of identity function into the TCK
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22139
diff
changeset
|
798 public void testPrimitiveidentityLong() throws Exception { |
92906003d607
Adding check of behavior of identity function into the TCK
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22139
diff
changeset
|
799 String id = identity(); |
92906003d607
Adding check of behavior of identity function into the TCK
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22139
diff
changeset
|
800 if (id == null) { |
92906003d607
Adding check of behavior of identity function into the TCK
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22139
diff
changeset
|
801 return; |
92906003d607
Adding check of behavior of identity function into the TCK
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22139
diff
changeset
|
802 } |
22170
796f0fef110e
Renaming to PolyglotEngine
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22168
diff
changeset
|
803 PolyglotEngine.Value apply = findGlobalSymbol(id); |
22140
92906003d607
Adding check of behavior of identity function into the TCK
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22139
diff
changeset
|
804 |
92906003d607
Adding check of behavior of identity function into the TCK
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22139
diff
changeset
|
805 long value = RANDOM.nextInt(1000); |
92906003d607
Adding check of behavior of identity function into the TCK
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22139
diff
changeset
|
806 |
22436
46a6d3eb790c
Adopt TCK and Polyglot after changes to execute and invoke message
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22382
diff
changeset
|
807 Number n = (Number) apply.execute(value).get(); |
22140
92906003d607
Adding check of behavior of identity function into the TCK
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22139
diff
changeset
|
808 assertEquals("The same value returned", value, n.longValue()); |
92906003d607
Adding check of behavior of identity function into the TCK
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22139
diff
changeset
|
809 } |
92906003d607
Adding check of behavior of identity function into the TCK
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22139
diff
changeset
|
810 |
92906003d607
Adding check of behavior of identity function into the TCK
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22139
diff
changeset
|
811 @Test |
22423
70a10a9f28ad
Verify that primitive data (numbers as well as String) can be passed into a language as boxed TruffleObject instances
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22422
diff
changeset
|
812 public void testPrimitiveidentityBoxedLong() throws Exception { |
70a10a9f28ad
Verify that primitive data (numbers as well as String) can be passed into a language as boxed TruffleObject instances
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22422
diff
changeset
|
813 String id = identity(); |
70a10a9f28ad
Verify that primitive data (numbers as well as String) can be passed into a language as boxed TruffleObject instances
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22422
diff
changeset
|
814 if (id == null) { |
70a10a9f28ad
Verify that primitive data (numbers as well as String) can be passed into a language as boxed TruffleObject instances
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22422
diff
changeset
|
815 return; |
70a10a9f28ad
Verify that primitive data (numbers as well as String) can be passed into a language as boxed TruffleObject instances
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22422
diff
changeset
|
816 } |
70a10a9f28ad
Verify that primitive data (numbers as well as String) can be passed into a language as boxed TruffleObject instances
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22422
diff
changeset
|
817 PolyglotEngine.Value apply = findGlobalSymbol(id); |
70a10a9f28ad
Verify that primitive data (numbers as well as String) can be passed into a language as boxed TruffleObject instances
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22422
diff
changeset
|
818 |
70a10a9f28ad
Verify that primitive data (numbers as well as String) can be passed into a language as boxed TruffleObject instances
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22422
diff
changeset
|
819 long value = RANDOM.nextInt(1000); |
70a10a9f28ad
Verify that primitive data (numbers as well as String) can be passed into a language as boxed TruffleObject instances
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22422
diff
changeset
|
820 BoxedValue boxed = new BoxedValue(value); |
70a10a9f28ad
Verify that primitive data (numbers as well as String) can be passed into a language as boxed TruffleObject instances
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22422
diff
changeset
|
821 |
22436
46a6d3eb790c
Adopt TCK and Polyglot after changes to execute and invoke message
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22382
diff
changeset
|
822 Number n = (Number) apply.execute(boxed).get(); |
22423
70a10a9f28ad
Verify that primitive data (numbers as well as String) can be passed into a language as boxed TruffleObject instances
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22422
diff
changeset
|
823 assertEquals("The same value returned", value, n.longValue()); |
70a10a9f28ad
Verify that primitive data (numbers as well as String) can be passed into a language as boxed TruffleObject instances
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22422
diff
changeset
|
824 } |
70a10a9f28ad
Verify that primitive data (numbers as well as String) can be passed into a language as boxed TruffleObject instances
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22422
diff
changeset
|
825 |
70a10a9f28ad
Verify that primitive data (numbers as well as String) can be passed into a language as boxed TruffleObject instances
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22422
diff
changeset
|
826 @Test |
22140
92906003d607
Adding check of behavior of identity function into the TCK
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22139
diff
changeset
|
827 public void testPrimitiveidentityFloat() throws Exception { |
92906003d607
Adding check of behavior of identity function into the TCK
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22139
diff
changeset
|
828 String id = identity(); |
92906003d607
Adding check of behavior of identity function into the TCK
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22139
diff
changeset
|
829 if (id == null) { |
92906003d607
Adding check of behavior of identity function into the TCK
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22139
diff
changeset
|
830 return; |
92906003d607
Adding check of behavior of identity function into the TCK
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22139
diff
changeset
|
831 } |
22170
796f0fef110e
Renaming to PolyglotEngine
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22168
diff
changeset
|
832 PolyglotEngine.Value apply = findGlobalSymbol(id); |
22140
92906003d607
Adding check of behavior of identity function into the TCK
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22139
diff
changeset
|
833 |
92906003d607
Adding check of behavior of identity function into the TCK
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22139
diff
changeset
|
834 float value = RANDOM.nextInt(1000) + RANDOM.nextFloat(); |
92906003d607
Adding check of behavior of identity function into the TCK
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22139
diff
changeset
|
835 |
22436
46a6d3eb790c
Adopt TCK and Polyglot after changes to execute and invoke message
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22382
diff
changeset
|
836 Number n = (Number) apply.execute(value).get(); |
22542
f8fb609939a7
Give implementors of the TCK control over comparing doubles.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22525
diff
changeset
|
837 assertDouble("The same value returned", value, n.floatValue()); |
22140
92906003d607
Adding check of behavior of identity function into the TCK
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22139
diff
changeset
|
838 } |
92906003d607
Adding check of behavior of identity function into the TCK
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22139
diff
changeset
|
839 |
92906003d607
Adding check of behavior of identity function into the TCK
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22139
diff
changeset
|
840 @Test |
22423
70a10a9f28ad
Verify that primitive data (numbers as well as String) can be passed into a language as boxed TruffleObject instances
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22422
diff
changeset
|
841 public void testPrimitiveidentityBoxedFloat() throws Exception { |
70a10a9f28ad
Verify that primitive data (numbers as well as String) can be passed into a language as boxed TruffleObject instances
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22422
diff
changeset
|
842 String id = identity(); |
70a10a9f28ad
Verify that primitive data (numbers as well as String) can be passed into a language as boxed TruffleObject instances
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22422
diff
changeset
|
843 if (id == null) { |
70a10a9f28ad
Verify that primitive data (numbers as well as String) can be passed into a language as boxed TruffleObject instances
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22422
diff
changeset
|
844 return; |
70a10a9f28ad
Verify that primitive data (numbers as well as String) can be passed into a language as boxed TruffleObject instances
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22422
diff
changeset
|
845 } |
70a10a9f28ad
Verify that primitive data (numbers as well as String) can be passed into a language as boxed TruffleObject instances
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22422
diff
changeset
|
846 PolyglotEngine.Value apply = findGlobalSymbol(id); |
70a10a9f28ad
Verify that primitive data (numbers as well as String) can be passed into a language as boxed TruffleObject instances
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22422
diff
changeset
|
847 |
70a10a9f28ad
Verify that primitive data (numbers as well as String) can be passed into a language as boxed TruffleObject instances
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22422
diff
changeset
|
848 float value = RANDOM.nextInt(1000) + RANDOM.nextFloat(); |
70a10a9f28ad
Verify that primitive data (numbers as well as String) can be passed into a language as boxed TruffleObject instances
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22422
diff
changeset
|
849 BoxedValue boxed = new BoxedValue(value); |
70a10a9f28ad
Verify that primitive data (numbers as well as String) can be passed into a language as boxed TruffleObject instances
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22422
diff
changeset
|
850 |
22436
46a6d3eb790c
Adopt TCK and Polyglot after changes to execute and invoke message
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22382
diff
changeset
|
851 Number n = (Number) apply.execute(boxed).get(); |
22542
f8fb609939a7
Give implementors of the TCK control over comparing doubles.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22525
diff
changeset
|
852 assertDouble("The same value returned", value, n.floatValue()); |
22423
70a10a9f28ad
Verify that primitive data (numbers as well as String) can be passed into a language as boxed TruffleObject instances
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22422
diff
changeset
|
853 } |
70a10a9f28ad
Verify that primitive data (numbers as well as String) can be passed into a language as boxed TruffleObject instances
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22422
diff
changeset
|
854 |
70a10a9f28ad
Verify that primitive data (numbers as well as String) can be passed into a language as boxed TruffleObject instances
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22422
diff
changeset
|
855 @Test |
22140
92906003d607
Adding check of behavior of identity function into the TCK
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22139
diff
changeset
|
856 public void testPrimitiveidentityDouble() throws Exception { |
92906003d607
Adding check of behavior of identity function into the TCK
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22139
diff
changeset
|
857 String id = identity(); |
92906003d607
Adding check of behavior of identity function into the TCK
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22139
diff
changeset
|
858 if (id == null) { |
92906003d607
Adding check of behavior of identity function into the TCK
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22139
diff
changeset
|
859 return; |
92906003d607
Adding check of behavior of identity function into the TCK
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22139
diff
changeset
|
860 } |
22170
796f0fef110e
Renaming to PolyglotEngine
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22168
diff
changeset
|
861 PolyglotEngine.Value apply = findGlobalSymbol(id); |
22140
92906003d607
Adding check of behavior of identity function into the TCK
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22139
diff
changeset
|
862 |
92906003d607
Adding check of behavior of identity function into the TCK
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22139
diff
changeset
|
863 double value = RANDOM.nextInt(1000) + RANDOM.nextDouble(); |
92906003d607
Adding check of behavior of identity function into the TCK
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22139
diff
changeset
|
864 |
22436
46a6d3eb790c
Adopt TCK and Polyglot after changes to execute and invoke message
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22382
diff
changeset
|
865 Number n = (Number) apply.execute(value).get(); |
22542
f8fb609939a7
Give implementors of the TCK control over comparing doubles.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22525
diff
changeset
|
866 assertDouble("The same value returned", value, n.doubleValue()); |
22140
92906003d607
Adding check of behavior of identity function into the TCK
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22139
diff
changeset
|
867 } |
92906003d607
Adding check of behavior of identity function into the TCK
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22139
diff
changeset
|
868 |
92906003d607
Adding check of behavior of identity function into the TCK
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22139
diff
changeset
|
869 @Test |
22423
70a10a9f28ad
Verify that primitive data (numbers as well as String) can be passed into a language as boxed TruffleObject instances
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22422
diff
changeset
|
870 public void testPrimitiveidentityBoxedDouble() throws Exception { |
70a10a9f28ad
Verify that primitive data (numbers as well as String) can be passed into a language as boxed TruffleObject instances
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22422
diff
changeset
|
871 String id = identity(); |
70a10a9f28ad
Verify that primitive data (numbers as well as String) can be passed into a language as boxed TruffleObject instances
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22422
diff
changeset
|
872 if (id == null) { |
70a10a9f28ad
Verify that primitive data (numbers as well as String) can be passed into a language as boxed TruffleObject instances
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22422
diff
changeset
|
873 return; |
70a10a9f28ad
Verify that primitive data (numbers as well as String) can be passed into a language as boxed TruffleObject instances
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22422
diff
changeset
|
874 } |
70a10a9f28ad
Verify that primitive data (numbers as well as String) can be passed into a language as boxed TruffleObject instances
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22422
diff
changeset
|
875 PolyglotEngine.Value apply = findGlobalSymbol(id); |
70a10a9f28ad
Verify that primitive data (numbers as well as String) can be passed into a language as boxed TruffleObject instances
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22422
diff
changeset
|
876 |
70a10a9f28ad
Verify that primitive data (numbers as well as String) can be passed into a language as boxed TruffleObject instances
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22422
diff
changeset
|
877 double value = RANDOM.nextInt(1000) + RANDOM.nextDouble(); |
70a10a9f28ad
Verify that primitive data (numbers as well as String) can be passed into a language as boxed TruffleObject instances
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22422
diff
changeset
|
878 BoxedValue boxed = new BoxedValue(value); |
70a10a9f28ad
Verify that primitive data (numbers as well as String) can be passed into a language as boxed TruffleObject instances
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22422
diff
changeset
|
879 |
22436
46a6d3eb790c
Adopt TCK and Polyglot after changes to execute and invoke message
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22382
diff
changeset
|
880 Number n = (Number) apply.execute(boxed).get(); |
22542
f8fb609939a7
Give implementors of the TCK control over comparing doubles.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22525
diff
changeset
|
881 assertDouble("The same value returned", value, n.doubleValue()); |
22423
70a10a9f28ad
Verify that primitive data (numbers as well as String) can be passed into a language as boxed TruffleObject instances
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22422
diff
changeset
|
882 } |
70a10a9f28ad
Verify that primitive data (numbers as well as String) can be passed into a language as boxed TruffleObject instances
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22422
diff
changeset
|
883 |
70a10a9f28ad
Verify that primitive data (numbers as well as String) can be passed into a language as boxed TruffleObject instances
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22422
diff
changeset
|
884 @Test |
22422
30644770899d
Testing identity behavior for String values
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22382
diff
changeset
|
885 public void testPrimitiveidentityString() throws Exception { |
30644770899d
Testing identity behavior for String values
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22382
diff
changeset
|
886 String id = identity(); |
30644770899d
Testing identity behavior for String values
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22382
diff
changeset
|
887 if (id == null) { |
30644770899d
Testing identity behavior for String values
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22382
diff
changeset
|
888 return; |
30644770899d
Testing identity behavior for String values
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22382
diff
changeset
|
889 } |
30644770899d
Testing identity behavior for String values
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22382
diff
changeset
|
890 PolyglotEngine.Value apply = findGlobalSymbol(id); |
30644770899d
Testing identity behavior for String values
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22382
diff
changeset
|
891 |
30644770899d
Testing identity behavior for String values
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22382
diff
changeset
|
892 String value = "Value" + RANDOM.nextInt(1000) + RANDOM.nextDouble(); |
30644770899d
Testing identity behavior for String values
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22382
diff
changeset
|
893 |
22436
46a6d3eb790c
Adopt TCK and Polyglot after changes to execute and invoke message
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22382
diff
changeset
|
894 String ret = (String) apply.execute(value).get(); |
22422
30644770899d
Testing identity behavior for String values
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22382
diff
changeset
|
895 assertEquals("The same value returned", value, ret); |
30644770899d
Testing identity behavior for String values
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22382
diff
changeset
|
896 } |
30644770899d
Testing identity behavior for String values
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22382
diff
changeset
|
897 |
30644770899d
Testing identity behavior for String values
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22382
diff
changeset
|
898 @Test |
22423
70a10a9f28ad
Verify that primitive data (numbers as well as String) can be passed into a language as boxed TruffleObject instances
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22422
diff
changeset
|
899 public void testPrimitiveidentityBoxedString() throws Exception { |
70a10a9f28ad
Verify that primitive data (numbers as well as String) can be passed into a language as boxed TruffleObject instances
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22422
diff
changeset
|
900 String id = identity(); |
70a10a9f28ad
Verify that primitive data (numbers as well as String) can be passed into a language as boxed TruffleObject instances
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22422
diff
changeset
|
901 if (id == null) { |
70a10a9f28ad
Verify that primitive data (numbers as well as String) can be passed into a language as boxed TruffleObject instances
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22422
diff
changeset
|
902 return; |
70a10a9f28ad
Verify that primitive data (numbers as well as String) can be passed into a language as boxed TruffleObject instances
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22422
diff
changeset
|
903 } |
70a10a9f28ad
Verify that primitive data (numbers as well as String) can be passed into a language as boxed TruffleObject instances
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22422
diff
changeset
|
904 PolyglotEngine.Value apply = findGlobalSymbol(id); |
70a10a9f28ad
Verify that primitive data (numbers as well as String) can be passed into a language as boxed TruffleObject instances
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22422
diff
changeset
|
905 |
70a10a9f28ad
Verify that primitive data (numbers as well as String) can be passed into a language as boxed TruffleObject instances
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22422
diff
changeset
|
906 String value = "Value" + RANDOM.nextInt(1000) + RANDOM.nextDouble(); |
70a10a9f28ad
Verify that primitive data (numbers as well as String) can be passed into a language as boxed TruffleObject instances
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22422
diff
changeset
|
907 BoxedValue boxed = new BoxedValue(value); |
70a10a9f28ad
Verify that primitive data (numbers as well as String) can be passed into a language as boxed TruffleObject instances
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22422
diff
changeset
|
908 |
22436
46a6d3eb790c
Adopt TCK and Polyglot after changes to execute and invoke message
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22382
diff
changeset
|
909 String ret = (String) apply.execute(boxed).get(); |
22423
70a10a9f28ad
Verify that primitive data (numbers as well as String) can be passed into a language as boxed TruffleObject instances
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22422
diff
changeset
|
910 assertEquals("The same value returned", value, ret); |
70a10a9f28ad
Verify that primitive data (numbers as well as String) can be passed into a language as boxed TruffleObject instances
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22422
diff
changeset
|
911 } |
70a10a9f28ad
Verify that primitive data (numbers as well as String) can be passed into a language as boxed TruffleObject instances
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22422
diff
changeset
|
912 |
70a10a9f28ad
Verify that primitive data (numbers as well as String) can be passed into a language as boxed TruffleObject instances
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22422
diff
changeset
|
913 @Test |
22140
92906003d607
Adding check of behavior of identity function into the TCK
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22139
diff
changeset
|
914 public void testPrimitiveIdentityForeignObject() throws Exception { |
92906003d607
Adding check of behavior of identity function into the TCK
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22139
diff
changeset
|
915 String id = identity(); |
92906003d607
Adding check of behavior of identity function into the TCK
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22139
diff
changeset
|
916 if (id == null) { |
92906003d607
Adding check of behavior of identity function into the TCK
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22139
diff
changeset
|
917 return; |
92906003d607
Adding check of behavior of identity function into the TCK
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22139
diff
changeset
|
918 } |
22170
796f0fef110e
Renaming to PolyglotEngine
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22168
diff
changeset
|
919 PolyglotEngine.Value apply = findGlobalSymbol(id); |
22140
92906003d607
Adding check of behavior of identity function into the TCK
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22139
diff
changeset
|
920 |
92906003d607
Adding check of behavior of identity function into the TCK
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22139
diff
changeset
|
921 TruffleObject fn = JavaInterop.asTruffleFunction(LongBinaryOperation.class, new MaxMinObject(true)); |
92906003d607
Adding check of behavior of identity function into the TCK
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22139
diff
changeset
|
922 |
22436
46a6d3eb790c
Adopt TCK and Polyglot after changes to execute and invoke message
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22382
diff
changeset
|
923 Object ret = apply.execute(fn).get(); |
22200
7abcbeb12d08
Creating a TruffleObject that knows its PolyglotEngine and wrapping all values returned from the engine by it, so it is always clear into which engine context an object belongs.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22173
diff
changeset
|
924 assertSameTruffleObject("The same value returned", fn, ret); |
22140
92906003d607
Adding check of behavior of identity function into the TCK
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22139
diff
changeset
|
925 } |
92906003d607
Adding check of behavior of identity function into the TCK
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22139
diff
changeset
|
926 |
92906003d607
Adding check of behavior of identity function into the TCK
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22139
diff
changeset
|
927 @Test |
22046
e7c2d36daf72
TruffleLanguage.parse method to convert a source to CallTarget. Basic caching to make sure the code is shared among tenants in one JVM.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21960
diff
changeset
|
928 public void testCoExistanceOfMultipleLanguageInstances() throws Exception { |
e7c2d36daf72
TruffleLanguage.parse method to convert a source to CallTarget. Basic caching to make sure the code is shared among tenants in one JVM.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21960
diff
changeset
|
929 final String countMethod = countInvocations(); |
22170
796f0fef110e
Renaming to PolyglotEngine
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22168
diff
changeset
|
930 PolyglotEngine.Value count1 = findGlobalSymbol(countMethod); |
796f0fef110e
Renaming to PolyglotEngine
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22168
diff
changeset
|
931 PolyglotEngine vm1 = tckVM; |
22046
e7c2d36daf72
TruffleLanguage.parse method to convert a source to CallTarget. Basic caching to make sure the code is shared among tenants in one JVM.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21960
diff
changeset
|
932 tckVM = null; // clean-up |
22170
796f0fef110e
Renaming to PolyglotEngine
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22168
diff
changeset
|
933 PolyglotEngine.Value count2 = findGlobalSymbol(countMethod); |
796f0fef110e
Renaming to PolyglotEngine
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22168
diff
changeset
|
934 PolyglotEngine vm2 = tckVM; |
22076
f54d7e045a37
Verify the two TruffleVM instances are different - otherwise the isolation cannot work
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22046
diff
changeset
|
935 |
f54d7e045a37
Verify the two TruffleVM instances are different - otherwise the isolation cannot work
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22046
diff
changeset
|
936 assertNotSame("Two virtual machines allocated", vm1, vm2); |
22046
e7c2d36daf72
TruffleLanguage.parse method to convert a source to CallTarget. Basic caching to make sure the code is shared among tenants in one JVM.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21960
diff
changeset
|
937 |
e7c2d36daf72
TruffleLanguage.parse method to convert a source to CallTarget. Basic caching to make sure the code is shared among tenants in one JVM.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21960
diff
changeset
|
938 int prev1 = 0; |
e7c2d36daf72
TruffleLanguage.parse method to convert a source to CallTarget. Basic caching to make sure the code is shared among tenants in one JVM.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21960
diff
changeset
|
939 int prev2 = 0; |
22543
0ef597d27256
Making sure the values of random input variables are printed in case of failure
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22542
diff
changeset
|
940 StringBuilder log = new StringBuilder(); |
22046
e7c2d36daf72
TruffleLanguage.parse method to convert a source to CallTarget. Basic caching to make sure the code is shared among tenants in one JVM.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21960
diff
changeset
|
941 for (int i = 0; i < 10; i++) { |
22135
e70b20f4bb00
Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22121
diff
changeset
|
942 int quantum = RANDOM.nextInt(10); |
22543
0ef597d27256
Making sure the values of random input variables are printed in case of failure
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22542
diff
changeset
|
943 log.append("quantum" + i + " is " + quantum + "\n"); |
22046
e7c2d36daf72
TruffleLanguage.parse method to convert a source to CallTarget. Basic caching to make sure the code is shared among tenants in one JVM.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21960
diff
changeset
|
944 for (int j = 0; j < quantum; j++) { |
22436
46a6d3eb790c
Adopt TCK and Polyglot after changes to execute and invoke message
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22382
diff
changeset
|
945 Object res = count1.execute().get(); |
22543
0ef597d27256
Making sure the values of random input variables are printed in case of failure
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22542
diff
changeset
|
946 assert res instanceof Number : "expecting number: " + res + "\n" + log; |
22135
e70b20f4bb00
Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22121
diff
changeset
|
947 ++prev1; |
22543
0ef597d27256
Making sure the values of random input variables are printed in case of failure
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22542
diff
changeset
|
948 assert ((Number) res).intValue() == prev1 : "expecting " + prev1 + " but was " + res + "\n" + log; |
22046
e7c2d36daf72
TruffleLanguage.parse method to convert a source to CallTarget. Basic caching to make sure the code is shared among tenants in one JVM.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21960
diff
changeset
|
949 } |
e7c2d36daf72
TruffleLanguage.parse method to convert a source to CallTarget. Basic caching to make sure the code is shared among tenants in one JVM.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21960
diff
changeset
|
950 for (int j = 0; j < quantum; j++) { |
22436
46a6d3eb790c
Adopt TCK and Polyglot after changes to execute and invoke message
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22382
diff
changeset
|
951 Object res = count2.execute().get(); |
22543
0ef597d27256
Making sure the values of random input variables are printed in case of failure
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22542
diff
changeset
|
952 assert res instanceof Number : "expecting number: " + res + "\n" + log; |
22135
e70b20f4bb00
Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22121
diff
changeset
|
953 ++prev2; |
22543
0ef597d27256
Making sure the values of random input variables are printed in case of failure
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22542
diff
changeset
|
954 assert ((Number) res).intValue() == prev2 : "expecting " + prev2 + " but was " + res + "\n" + log; |
22046
e7c2d36daf72
TruffleLanguage.parse method to convert a source to CallTarget. Basic caching to make sure the code is shared among tenants in one JVM.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21960
diff
changeset
|
955 } |
22543
0ef597d27256
Making sure the values of random input variables are printed in case of failure
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22542
diff
changeset
|
956 assert prev1 == prev2 : "At round " + i + " the same number of invocations " + prev1 + " vs. " + prev2 + "\n" + log; |
22046
e7c2d36daf72
TruffleLanguage.parse method to convert a source to CallTarget. Basic caching to make sure the code is shared among tenants in one JVM.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21960
diff
changeset
|
957 } |
22278
85a6db6624ab
Simplifying the way to obtain Language.globalObject
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22200
diff
changeset
|
958 } |
22046
e7c2d36daf72
TruffleLanguage.parse method to convert a source to CallTarget. Basic caching to make sure the code is shared among tenants in one JVM.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21960
diff
changeset
|
959 |
22278
85a6db6624ab
Simplifying the way to obtain Language.globalObject
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22200
diff
changeset
|
960 @Test |
85a6db6624ab
Simplifying the way to obtain Language.globalObject
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22200
diff
changeset
|
961 public void testGlobalObjectIsAccessible() throws Exception { |
85a6db6624ab
Simplifying the way to obtain Language.globalObject
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22200
diff
changeset
|
962 String globalObjectFunction = globalObject(); |
85a6db6624ab
Simplifying the way to obtain Language.globalObject
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22200
diff
changeset
|
963 if (globalObjectFunction == null) { |
85a6db6624ab
Simplifying the way to obtain Language.globalObject
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22200
diff
changeset
|
964 return; |
85a6db6624ab
Simplifying the way to obtain Language.globalObject
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22200
diff
changeset
|
965 } |
85a6db6624ab
Simplifying the way to obtain Language.globalObject
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22200
diff
changeset
|
966 |
85a6db6624ab
Simplifying the way to obtain Language.globalObject
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22200
diff
changeset
|
967 Language language = vm().getLanguages().get(mimeType()); |
85a6db6624ab
Simplifying the way to obtain Language.globalObject
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22200
diff
changeset
|
968 assertNotNull("Langugage for " + mimeType() + " found", language); |
85a6db6624ab
Simplifying the way to obtain Language.globalObject
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22200
diff
changeset
|
969 |
85a6db6624ab
Simplifying the way to obtain Language.globalObject
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22200
diff
changeset
|
970 PolyglotEngine.Value function = vm().findGlobalSymbol(globalObjectFunction); |
22436
46a6d3eb790c
Adopt TCK and Polyglot after changes to execute and invoke message
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22382
diff
changeset
|
971 Object global = function.execute().get(); |
22278
85a6db6624ab
Simplifying the way to obtain Language.globalObject
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22200
diff
changeset
|
972 assertEquals("Global from the language same with Java obtained one", language.getGlobalObject().get(), global); |
22046
e7c2d36daf72
TruffleLanguage.parse method to convert a source to CallTarget. Basic caching to make sure the code is shared among tenants in one JVM.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21960
diff
changeset
|
973 } |
e7c2d36daf72
TruffleLanguage.parse method to convert a source to CallTarget. Basic caching to make sure the code is shared among tenants in one JVM.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21960
diff
changeset
|
974 |
22375
78594d342228
Give Truffle languages access to evaluation functions of other languages.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22284
diff
changeset
|
975 @Test |
78594d342228
Give Truffle languages access to evaluation functions of other languages.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22284
diff
changeset
|
976 public void testEvaluateSource() throws Exception { |
78594d342228
Give Truffle languages access to evaluation functions of other languages.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22284
diff
changeset
|
977 Language language = vm().getLanguages().get(mimeType()); |
78594d342228
Give Truffle languages access to evaluation functions of other languages.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22284
diff
changeset
|
978 assertNotNull("Langugage for " + mimeType() + " found", language); |
78594d342228
Give Truffle languages access to evaluation functions of other languages.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22284
diff
changeset
|
979 |
78594d342228
Give Truffle languages access to evaluation functions of other languages.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22284
diff
changeset
|
980 PolyglotEngine.Value function = vm().findGlobalSymbol(evaluateSource()); |
78594d342228
Give Truffle languages access to evaluation functions of other languages.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22284
diff
changeset
|
981 assertNotNull(evaluateSource() + " found", function); |
78594d342228
Give Truffle languages access to evaluation functions of other languages.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22284
diff
changeset
|
982 |
22378
06bdf4a43126
Adding parse with argument names into the API and TCK
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22375
diff
changeset
|
983 double expect = Math.floor(RANDOM.nextDouble() * 100000.0) / 10.0; |
22436
46a6d3eb790c
Adopt TCK and Polyglot after changes to execute and invoke message
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22382
diff
changeset
|
984 Object parsed = function.execute("application/x-tck", "" + expect).get(); |
22375
78594d342228
Give Truffle languages access to evaluation functions of other languages.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22284
diff
changeset
|
985 assertTrue("Expecting numeric result, was:" + expect, parsed instanceof Number); |
22382
fb607f23d1eb
Apply formating rules
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22381
diff
changeset
|
986 double value = ((Number) parsed).doubleValue(); |
22542
f8fb609939a7
Give implementors of the TCK control over comparing doubles.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22525
diff
changeset
|
987 assertDouble("Gets the double", expect, value); |
22375
78594d342228
Give Truffle languages access to evaluation functions of other languages.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22284
diff
changeset
|
988 } |
78594d342228
Give Truffle languages access to evaluation functions of other languages.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22284
diff
changeset
|
989 |
22378
06bdf4a43126
Adding parse with argument names into the API and TCK
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22375
diff
changeset
|
990 @Test |
06bdf4a43126
Adding parse with argument names into the API and TCK
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22375
diff
changeset
|
991 public void multiplyTwoVariables() throws Exception { |
22382
fb607f23d1eb
Apply formating rules
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22381
diff
changeset
|
992 final String firstVar = "var" + (char) ('A' + RANDOM.nextInt(24)); |
fb607f23d1eb
Apply formating rules
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22381
diff
changeset
|
993 final String secondVar = "var" + (char) ('0' + RANDOM.nextInt(10)); |
22378
06bdf4a43126
Adding parse with argument names into the API and TCK
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22375
diff
changeset
|
994 String mulCode = multiplyCode(firstVar, secondVar); |
22382
fb607f23d1eb
Apply formating rules
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22381
diff
changeset
|
995 Source source = Source.fromText("TCK42:" + mimeType() + ":" + mulCode, "evaluate " + firstVar + " * " + secondVar).withMimeType("application/x-tck"); |
22378
06bdf4a43126
Adding parse with argument names into the API and TCK
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22375
diff
changeset
|
996 final PolyglotEngine.Value evalSource = vm().eval(source); |
22436
46a6d3eb790c
Adopt TCK and Polyglot after changes to execute and invoke message
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22382
diff
changeset
|
997 final PolyglotEngine.Value invokeMul = evalSource.execute(firstVar, secondVar); |
22378
06bdf4a43126
Adding parse with argument names into the API and TCK
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22375
diff
changeset
|
998 Object result = invokeMul.get(); |
22543
0ef597d27256
Making sure the values of random input variables are printed in case of failure
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22542
diff
changeset
|
999 assertTrue("Expecting numeric result, was:" + result + " for " + firstVar + " and " + secondVar, result instanceof Number); |
0ef597d27256
Making sure the values of random input variables are printed in case of failure
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22542
diff
changeset
|
1000 assertEquals("Right value for " + firstVar + " and " + secondVar, 42, ((Number) result).intValue()); |
22378
06bdf4a43126
Adding parse with argument names into the API and TCK
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22375
diff
changeset
|
1001 } |
06bdf4a43126
Adding parse with argument names into the API and TCK
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22375
diff
changeset
|
1002 |
22488
fa7b15454c66
Add ComplexNumber test to TCK
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22437
diff
changeset
|
1003 @Test |
fa7b15454c66
Add ComplexNumber test to TCK
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22437
diff
changeset
|
1004 public void testAddComplexNumbers() throws Exception { |
fa7b15454c66
Add ComplexNumber test to TCK
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22437
diff
changeset
|
1005 String id = complexAdd(); |
fa7b15454c66
Add ComplexNumber test to TCK
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22437
diff
changeset
|
1006 if (id == null) { |
fa7b15454c66
Add ComplexNumber test to TCK
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22437
diff
changeset
|
1007 return; |
fa7b15454c66
Add ComplexNumber test to TCK
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22437
diff
changeset
|
1008 } |
fa7b15454c66
Add ComplexNumber test to TCK
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22437
diff
changeset
|
1009 PolyglotEngine.Value apply = findGlobalSymbol(id); |
fa7b15454c66
Add ComplexNumber test to TCK
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22437
diff
changeset
|
1010 |
fa7b15454c66
Add ComplexNumber test to TCK
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22437
diff
changeset
|
1011 ComplexNumber a = new ComplexNumber(32, 10); |
fa7b15454c66
Add ComplexNumber test to TCK
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22437
diff
changeset
|
1012 ComplexNumber b = new ComplexNumber(10, 32); |
fa7b15454c66
Add ComplexNumber test to TCK
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22437
diff
changeset
|
1013 |
fa7b15454c66
Add ComplexNumber test to TCK
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22437
diff
changeset
|
1014 apply.execute(a, b); |
fa7b15454c66
Add ComplexNumber test to TCK
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22437
diff
changeset
|
1015 |
fa7b15454c66
Add ComplexNumber test to TCK
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22437
diff
changeset
|
1016 assertEquals(42.0, a.get(ComplexNumber.REAL_IDENTIFIER), 0.1); |
fa7b15454c66
Add ComplexNumber test to TCK
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22437
diff
changeset
|
1017 assertEquals(42.0, a.get(ComplexNumber.IMAGINARY_IDENTIFIER), 0.1); |
fa7b15454c66
Add ComplexNumber test to TCK
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22437
diff
changeset
|
1018 } |
fa7b15454c66
Add ComplexNumber test to TCK
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22437
diff
changeset
|
1019 |
22495
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
1020 @Test |
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
1021 public void testSumRealOfComplexNumbersA() throws Exception { |
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
1022 String id = complexSumReal(); |
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
1023 if (id == null) { |
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
1024 return; |
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
1025 } |
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
1026 PolyglotEngine.Value apply = findGlobalSymbol(id); |
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
1027 |
22496
b3569a53c24c
Refactor and improve ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22495
diff
changeset
|
1028 ComplexNumbersRowBased numbers = new ComplexNumbersRowBased(new double[]{2, -1, 30, -1, 10, -1}); |
22495
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
1029 |
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
1030 Number n = (Number) apply.execute(numbers).get(); |
22542
f8fb609939a7
Give implementors of the TCK control over comparing doubles.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22525
diff
changeset
|
1031 assertDouble("The same value returned", 42.0, n.doubleValue()); |
22495
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
1032 } |
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
1033 |
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
1034 @Test |
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
1035 public void testSumRealOfComplexNumbersB() throws Exception { |
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
1036 String id = complexSumReal(); |
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
1037 if (id == null) { |
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
1038 return; |
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
1039 } |
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
1040 PolyglotEngine.Value apply = findGlobalSymbol(id); |
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
1041 |
22496
b3569a53c24c
Refactor and improve ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22495
diff
changeset
|
1042 ComplexNumbersColumnBased numbers = new ComplexNumbersColumnBased(new double[]{2, 30, 10}, new double[]{-1, -1, -1}); |
22495
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
1043 |
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
1044 Number n = (Number) apply.execute(numbers).get(); |
22542
f8fb609939a7
Give implementors of the TCK control over comparing doubles.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22525
diff
changeset
|
1045 assertDouble("The same value returned", 42.0, n.doubleValue()); |
22495
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
1046 } |
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
1047 |
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
1048 @Test |
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
1049 public void testSumRealOfComplexNumbersAsStructuredDataRowBased() throws Exception { |
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
1050 String id = complexSumReal(); |
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
1051 if (id == null) { |
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
1052 return; |
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
1053 } |
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
1054 PolyglotEngine.Value apply = findGlobalSymbol(id); |
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
1055 |
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
1056 Schema schema = new Schema(3, true, Arrays.asList(ComplexNumber.REAL_IDENTIFIER, ComplexNumber.IMAGINARY_IDENTIFIER), Arrays.asList(Type.DOUBLE, Type.DOUBLE)); |
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
1057 byte[] buffer = new byte[(6 * Double.SIZE / Byte.SIZE)]; |
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
1058 putDoubles(buffer, new double[]{2, -1, 30, -1, 10, -1}); |
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
1059 StructuredData numbers = new StructuredData(buffer, schema); |
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
1060 |
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
1061 Number n = (Number) apply.execute(numbers).get(); |
22542
f8fb609939a7
Give implementors of the TCK control over comparing doubles.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22525
diff
changeset
|
1062 assertDouble("The same value returned", 42.0, n.doubleValue()); |
22495
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
1063 } |
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
1064 |
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
1065 @Test |
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
1066 public void testSumRealOfComplexNumbersAsStructuredDataColumnBased() throws Exception { |
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
1067 String id = complexSumReal(); |
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
1068 if (id == null) { |
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
1069 return; |
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
1070 } |
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
1071 PolyglotEngine.Value apply = findGlobalSymbol(id); |
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
1072 |
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
1073 Schema schema = new Schema(3, false, Arrays.asList(ComplexNumber.REAL_IDENTIFIER, ComplexNumber.IMAGINARY_IDENTIFIER), Arrays.asList(Type.DOUBLE, Type.DOUBLE)); |
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
1074 byte[] buffer = new byte[6 * Double.SIZE / Byte.SIZE]; |
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
1075 putDoubles(buffer, new double[]{2, 30, 10, -1, -1, -1}); |
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
1076 |
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
1077 StructuredData numbers = new StructuredData(buffer, schema); |
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
1078 |
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
1079 Number n = (Number) apply.execute(numbers).get(); |
22542
f8fb609939a7
Give implementors of the TCK control over comparing doubles.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22525
diff
changeset
|
1080 assertDouble("The same value returned", 42.0, n.doubleValue()); |
22495
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
1081 } |
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
1082 |
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
1083 @Test |
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
1084 public void testCopyComplexNumbersA() throws Exception { |
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
1085 String id = complexCopy(); |
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
1086 if (id == null) { |
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
1087 return; |
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
1088 } |
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
1089 PolyglotEngine.Value apply = findGlobalSymbol(id); |
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
1090 |
22496
b3569a53c24c
Refactor and improve ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22495
diff
changeset
|
1091 ComplexNumbersRowBased a = new ComplexNumbersRowBased(new double[]{-1, -1, -1, -1, -1, -1}); |
b3569a53c24c
Refactor and improve ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22495
diff
changeset
|
1092 ComplexNumbersRowBased b = new ComplexNumbersRowBased(new double[]{41, 42, 43, 44, 45, 46}); |
22495
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
1093 |
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
1094 apply.execute(a, b); |
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
1095 |
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
1096 Assert.assertArrayEquals(new double[]{41, 42, 43, 44, 45, 46}, a.getData(), 0.1); |
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
1097 } |
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
1098 |
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
1099 @Test |
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
1100 public void testCopyComplexNumbersB() throws Exception { |
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
1101 String id = complexCopy(); |
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
1102 if (id == null) { |
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
1103 return; |
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
1104 } |
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
1105 PolyglotEngine.Value apply = findGlobalSymbol(id); |
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
1106 |
22496
b3569a53c24c
Refactor and improve ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22495
diff
changeset
|
1107 ComplexNumbersColumnBased a = new ComplexNumbersColumnBased(new double[]{-1, -1, -1}, new double[]{-1, -1, -1}); |
b3569a53c24c
Refactor and improve ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22495
diff
changeset
|
1108 ComplexNumbersColumnBased b = new ComplexNumbersColumnBased(new double[]{41, 43, 45}, new double[]{42, 44, 46}); |
22495
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
1109 |
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
1110 apply.execute(a, b); |
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
1111 |
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
1112 Assert.assertArrayEquals(new double[]{41, 42, 43, 44, 45, 46}, a.getData(), 0.1); |
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
1113 } |
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
1114 |
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
1115 @Test |
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
1116 public void testCopyStructuredComplexToComplexNumbersA() throws Exception { |
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
1117 String id = complexCopy(); |
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
1118 if (id == null) { |
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
1119 return; |
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
1120 } |
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
1121 PolyglotEngine.Value apply = findGlobalSymbol(id); |
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
1122 |
22496
b3569a53c24c
Refactor and improve ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22495
diff
changeset
|
1123 ComplexNumbersRowBased a = new ComplexNumbersRowBased(new double[]{-1, -1, -1, -1, -1, -1}); |
22495
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
1124 |
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
1125 Schema schema = new Schema(3, true, Arrays.asList(ComplexNumber.REAL_IDENTIFIER, ComplexNumber.IMAGINARY_IDENTIFIER), Arrays.asList(Type.DOUBLE, Type.DOUBLE)); |
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
1126 byte[] buffer = new byte[6 * Double.SIZE / Byte.SIZE]; |
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
1127 putDoubles(buffer, new double[]{41, 42, 43, 44, 45, 46}); |
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
1128 |
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
1129 StructuredData b = new StructuredData(buffer, schema); |
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
1130 |
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
1131 apply.execute(a, b); |
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
1132 |
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
1133 Assert.assertArrayEquals(new double[]{41, 42, 43, 44, 45, 46}, a.getData(), 0.1); |
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
1134 } |
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
1135 |
22523
6ab540203853
Expanding TCK to cover reading and writing of object properties with various primitive types
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22496
diff
changeset
|
1136 @Test |
6ab540203853
Expanding TCK to cover reading and writing of object properties with various primitive types
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22496
diff
changeset
|
1137 public void readWriteByteValue() throws Exception { |
6ab540203853
Expanding TCK to cover reading and writing of object properties with various primitive types
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22496
diff
changeset
|
1138 String id = valuesObject(); |
6ab540203853
Expanding TCK to cover reading and writing of object properties with various primitive types
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22496
diff
changeset
|
1139 ValuesObject values = findGlobalSymbol(id).execute().as(ValuesObject.class); |
6ab540203853
Expanding TCK to cover reading and writing of object properties with various primitive types
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22496
diff
changeset
|
1140 assertEquals("Zero", 0, values.byteValue()); |
6ab540203853
Expanding TCK to cover reading and writing of object properties with various primitive types
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22496
diff
changeset
|
1141 final byte value = (byte) RANDOM.nextInt(128); |
6ab540203853
Expanding TCK to cover reading and writing of object properties with various primitive types
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22496
diff
changeset
|
1142 values.byteValue(value); |
6ab540203853
Expanding TCK to cover reading and writing of object properties with various primitive types
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22496
diff
changeset
|
1143 assertEquals("Correct value", value, values.byteValue()); |
6ab540203853
Expanding TCK to cover reading and writing of object properties with various primitive types
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22496
diff
changeset
|
1144 } |
6ab540203853
Expanding TCK to cover reading and writing of object properties with various primitive types
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22496
diff
changeset
|
1145 |
6ab540203853
Expanding TCK to cover reading and writing of object properties with various primitive types
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22496
diff
changeset
|
1146 @Test |
6ab540203853
Expanding TCK to cover reading and writing of object properties with various primitive types
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22496
diff
changeset
|
1147 public void readWriteShortValue() throws Exception { |
6ab540203853
Expanding TCK to cover reading and writing of object properties with various primitive types
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22496
diff
changeset
|
1148 String id = valuesObject(); |
6ab540203853
Expanding TCK to cover reading and writing of object properties with various primitive types
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22496
diff
changeset
|
1149 ValuesObject values = findGlobalSymbol(id).execute().as(ValuesObject.class); |
6ab540203853
Expanding TCK to cover reading and writing of object properties with various primitive types
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22496
diff
changeset
|
1150 assertEquals("Zero", 0, values.shortValue()); |
6ab540203853
Expanding TCK to cover reading and writing of object properties with various primitive types
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22496
diff
changeset
|
1151 final short value = (short) RANDOM.nextInt(32768); |
6ab540203853
Expanding TCK to cover reading and writing of object properties with various primitive types
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22496
diff
changeset
|
1152 values.shortValue(value); |
6ab540203853
Expanding TCK to cover reading and writing of object properties with various primitive types
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22496
diff
changeset
|
1153 assertEquals("Correct value", value, values.shortValue()); |
6ab540203853
Expanding TCK to cover reading and writing of object properties with various primitive types
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22496
diff
changeset
|
1154 } |
6ab540203853
Expanding TCK to cover reading and writing of object properties with various primitive types
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22496
diff
changeset
|
1155 |
6ab540203853
Expanding TCK to cover reading and writing of object properties with various primitive types
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22496
diff
changeset
|
1156 @Test |
6ab540203853
Expanding TCK to cover reading and writing of object properties with various primitive types
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22496
diff
changeset
|
1157 public void readWriteIntValue() throws Exception { |
6ab540203853
Expanding TCK to cover reading and writing of object properties with various primitive types
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22496
diff
changeset
|
1158 String id = valuesObject(); |
6ab540203853
Expanding TCK to cover reading and writing of object properties with various primitive types
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22496
diff
changeset
|
1159 ValuesObject values = findGlobalSymbol(id).execute().as(ValuesObject.class); |
6ab540203853
Expanding TCK to cover reading and writing of object properties with various primitive types
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22496
diff
changeset
|
1160 assertEquals("Zero", 0, values.intValue()); |
6ab540203853
Expanding TCK to cover reading and writing of object properties with various primitive types
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22496
diff
changeset
|
1161 final int value = RANDOM.nextInt(); |
6ab540203853
Expanding TCK to cover reading and writing of object properties with various primitive types
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22496
diff
changeset
|
1162 values.intValue(value); |
6ab540203853
Expanding TCK to cover reading and writing of object properties with various primitive types
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22496
diff
changeset
|
1163 assertEquals("Correct value", value, values.intValue()); |
6ab540203853
Expanding TCK to cover reading and writing of object properties with various primitive types
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22496
diff
changeset
|
1164 } |
6ab540203853
Expanding TCK to cover reading and writing of object properties with various primitive types
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22496
diff
changeset
|
1165 |
6ab540203853
Expanding TCK to cover reading and writing of object properties with various primitive types
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22496
diff
changeset
|
1166 @Test |
6ab540203853
Expanding TCK to cover reading and writing of object properties with various primitive types
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22496
diff
changeset
|
1167 public void readWriteFloatValue() throws Exception { |
6ab540203853
Expanding TCK to cover reading and writing of object properties with various primitive types
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22496
diff
changeset
|
1168 String id = valuesObject(); |
6ab540203853
Expanding TCK to cover reading and writing of object properties with various primitive types
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22496
diff
changeset
|
1169 ValuesObject values = findGlobalSymbol(id).execute().as(ValuesObject.class); |
22542
f8fb609939a7
Give implementors of the TCK control over comparing doubles.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22525
diff
changeset
|
1170 assertDouble("Zero", 0, values.floatValue()); |
22523
6ab540203853
Expanding TCK to cover reading and writing of object properties with various primitive types
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22496
diff
changeset
|
1171 final float value = RANDOM.nextFloat() * 1000.0f; |
6ab540203853
Expanding TCK to cover reading and writing of object properties with various primitive types
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22496
diff
changeset
|
1172 values.floatValue(value); |
22542
f8fb609939a7
Give implementors of the TCK control over comparing doubles.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22525
diff
changeset
|
1173 assertDouble("Correct value", value, values.floatValue()); |
22523
6ab540203853
Expanding TCK to cover reading and writing of object properties with various primitive types
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22496
diff
changeset
|
1174 } |
6ab540203853
Expanding TCK to cover reading and writing of object properties with various primitive types
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22496
diff
changeset
|
1175 |
6ab540203853
Expanding TCK to cover reading and writing of object properties with various primitive types
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22496
diff
changeset
|
1176 @Test |
6ab540203853
Expanding TCK to cover reading and writing of object properties with various primitive types
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22496
diff
changeset
|
1177 public void readWriteDoubleValue() throws Exception { |
6ab540203853
Expanding TCK to cover reading and writing of object properties with various primitive types
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22496
diff
changeset
|
1178 String id = valuesObject(); |
6ab540203853
Expanding TCK to cover reading and writing of object properties with various primitive types
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22496
diff
changeset
|
1179 ValuesObject values = findGlobalSymbol(id).execute().as(ValuesObject.class); |
22542
f8fb609939a7
Give implementors of the TCK control over comparing doubles.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22525
diff
changeset
|
1180 assertDouble("Zero", 0, values.doubleValue()); |
22523
6ab540203853
Expanding TCK to cover reading and writing of object properties with various primitive types
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22496
diff
changeset
|
1181 final double value = RANDOM.nextDouble() * 1000.0; |
6ab540203853
Expanding TCK to cover reading and writing of object properties with various primitive types
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22496
diff
changeset
|
1182 values.doubleValue(value); |
22542
f8fb609939a7
Give implementors of the TCK control over comparing doubles.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22525
diff
changeset
|
1183 assertDouble("Correct value", value, values.doubleValue()); |
22523
6ab540203853
Expanding TCK to cover reading and writing of object properties with various primitive types
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22496
diff
changeset
|
1184 } |
6ab540203853
Expanding TCK to cover reading and writing of object properties with various primitive types
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22496
diff
changeset
|
1185 |
6ab540203853
Expanding TCK to cover reading and writing of object properties with various primitive types
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22496
diff
changeset
|
1186 @Test |
6ab540203853
Expanding TCK to cover reading and writing of object properties with various primitive types
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22496
diff
changeset
|
1187 public void readWriteCharValue() throws Exception { |
6ab540203853
Expanding TCK to cover reading and writing of object properties with various primitive types
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22496
diff
changeset
|
1188 String id = valuesObject(); |
6ab540203853
Expanding TCK to cover reading and writing of object properties with various primitive types
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22496
diff
changeset
|
1189 ValuesObject values = findGlobalSymbol(id).execute().as(ValuesObject.class); |
6ab540203853
Expanding TCK to cover reading and writing of object properties with various primitive types
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22496
diff
changeset
|
1190 assertEquals("Zero", '0', values.charValue()); |
6ab540203853
Expanding TCK to cover reading and writing of object properties with various primitive types
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22496
diff
changeset
|
1191 String letters = "P\u0159\u00EDli\u0161 \u017Elu\u0165ou\u010Dk\u00FD k\u016F\u0148 \u00FAp\u011Bl \u010F\u00E1belsk\u00E9 \u00F3dy"; |
6ab540203853
Expanding TCK to cover reading and writing of object properties with various primitive types
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22496
diff
changeset
|
1192 final char value = letters.charAt(RANDOM.nextInt(letters.length())); |
6ab540203853
Expanding TCK to cover reading and writing of object properties with various primitive types
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22496
diff
changeset
|
1193 values.charValue(value); |
6ab540203853
Expanding TCK to cover reading and writing of object properties with various primitive types
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22496
diff
changeset
|
1194 assertEquals("Correct value", value, values.charValue()); |
6ab540203853
Expanding TCK to cover reading and writing of object properties with various primitive types
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22496
diff
changeset
|
1195 } |
6ab540203853
Expanding TCK to cover reading and writing of object properties with various primitive types
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22496
diff
changeset
|
1196 |
6ab540203853
Expanding TCK to cover reading and writing of object properties with various primitive types
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22496
diff
changeset
|
1197 @Test |
6ab540203853
Expanding TCK to cover reading and writing of object properties with various primitive types
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22496
diff
changeset
|
1198 public void readWriteBooleanValue() throws Exception { |
6ab540203853
Expanding TCK to cover reading and writing of object properties with various primitive types
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22496
diff
changeset
|
1199 String id = valuesObject(); |
6ab540203853
Expanding TCK to cover reading and writing of object properties with various primitive types
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22496
diff
changeset
|
1200 ValuesObject values = findGlobalSymbol(id).execute().as(ValuesObject.class); |
6ab540203853
Expanding TCK to cover reading and writing of object properties with various primitive types
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22496
diff
changeset
|
1201 assertEquals("False", false, values.booleanValue()); |
6ab540203853
Expanding TCK to cover reading and writing of object properties with various primitive types
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22496
diff
changeset
|
1202 values.booleanValue(true); |
6ab540203853
Expanding TCK to cover reading and writing of object properties with various primitive types
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22496
diff
changeset
|
1203 assertEquals("Correct value", true, values.booleanValue()); |
6ab540203853
Expanding TCK to cover reading and writing of object properties with various primitive types
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22496
diff
changeset
|
1204 values.booleanValue(false); |
6ab540203853
Expanding TCK to cover reading and writing of object properties with various primitive types
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22496
diff
changeset
|
1205 assertEquals("Correct value2", false, values.booleanValue()); |
6ab540203853
Expanding TCK to cover reading and writing of object properties with various primitive types
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22496
diff
changeset
|
1206 } |
6ab540203853
Expanding TCK to cover reading and writing of object properties with various primitive types
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22496
diff
changeset
|
1207 |
22495
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
1208 private static void putDoubles(byte[] buffer, double[] values) { |
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
1209 for (int index = 0; index < values.length; index++) { |
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
1210 int doubleSize = Double.SIZE / Byte.SIZE; |
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
1211 byte[] bytes = new byte[doubleSize]; |
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
1212 ByteBuffer.wrap(bytes).putDouble(values[index]); |
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
1213 for (int i = 0; i < doubleSize; i++) { |
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
1214 buffer[index * doubleSize + i] = bytes[i]; |
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
1215 } |
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
1216 } |
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
1217 } |
aeba89e1d8da
Add ComplexNumber sequence tests
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22488
diff
changeset
|
1218 |
22170
796f0fef110e
Renaming to PolyglotEngine
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22168
diff
changeset
|
1219 private PolyglotEngine.Value findGlobalSymbol(String name) throws Exception { |
796f0fef110e
Renaming to PolyglotEngine
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22168
diff
changeset
|
1220 PolyglotEngine.Value s = vm().findGlobalSymbol(name); |
21938
0a6e10379b9b
Keeping only Truffle-related modules in this repository
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
1221 assert s != null : "Symbol " + name + " is not found!"; |
0a6e10379b9b
Keeping only Truffle-related modules in this repository
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
1222 return s; |
0a6e10379b9b
Keeping only Truffle-related modules in this repository
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
1223 } |
22135
e70b20f4bb00
Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22121
diff
changeset
|
1224 |
22156
50056a161d7f
Replacing time out associated warnings by UnsupportedOperationException. Meaning of exception is probably more straightforward than a soft hint attempted before. Shouldn't influence the way things are build, if tests are skipped.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22142
diff
changeset
|
1225 private CompoundObject findCompoundSymbol() throws Exception { |
22135
e70b20f4bb00
Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22121
diff
changeset
|
1226 final String compoundObjectName = compoundObject(); |
22170
796f0fef110e
Renaming to PolyglotEngine
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22168
diff
changeset
|
1227 PolyglotEngine.Value s = vm().findGlobalSymbol(compoundObjectName); |
22135
e70b20f4bb00
Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22121
diff
changeset
|
1228 assert s != null : "Symbol " + compoundObjectName + " is not found!"; |
22436
46a6d3eb790c
Adopt TCK and Polyglot after changes to execute and invoke message
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
22382
diff
changeset
|
1229 final PolyglotEngine.Value value = s.execute(); |
22141
46384e637592
Make sure the proper TruffleVM execution context is re-set before invoking an operation on a JavaInterop wrapper obtained via Symbol.as method.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22140
diff
changeset
|
1230 CompoundObject obj = value.as(CompoundObject.class); |
46384e637592
Make sure the proper TruffleVM execution context is re-set before invoking an operation on a JavaInterop wrapper obtained via Symbol.as method.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22140
diff
changeset
|
1231 assertNotNull("Compound object for " + value + " found", obj); |
22135
e70b20f4bb00
Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22121
diff
changeset
|
1232 int traverse = RANDOM.nextInt(10); |
22141
46384e637592
Make sure the proper TruffleVM execution context is re-set before invoking an operation on a JavaInterop wrapper obtained via Symbol.as method.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22140
diff
changeset
|
1233 for (int i = 1; i <= traverse; i++) { |
22135
e70b20f4bb00
Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22121
diff
changeset
|
1234 obj = obj.returnsThis(); |
22141
46384e637592
Make sure the proper TruffleVM execution context is re-set before invoking an operation on a JavaInterop wrapper obtained via Symbol.as method.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22140
diff
changeset
|
1235 assertNotNull("Remains non-null even after " + i + " iteration", obj); |
22135
e70b20f4bb00
Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22121
diff
changeset
|
1236 } |
e70b20f4bb00
Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22121
diff
changeset
|
1237 return obj; |
e70b20f4bb00
Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22121
diff
changeset
|
1238 } |
e70b20f4bb00
Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22121
diff
changeset
|
1239 |
22200
7abcbeb12d08
Creating a TruffleObject that knows its PolyglotEngine and wrapping all values returned from the engine by it, so it is always clear into which engine context an object belongs.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22173
diff
changeset
|
1240 private static void assertSameTruffleObject(String msg, Object expected, Object actual) { |
7abcbeb12d08
Creating a TruffleObject that knows its PolyglotEngine and wrapping all values returned from the engine by it, so it is always clear into which engine context an object belongs.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22173
diff
changeset
|
1241 Object unExpected = unwrapTruffleObject(expected); |
7abcbeb12d08
Creating a TruffleObject that knows its PolyglotEngine and wrapping all values returned from the engine by it, so it is always clear into which engine context an object belongs.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22173
diff
changeset
|
1242 Object unAction = unwrapTruffleObject(actual); |
7abcbeb12d08
Creating a TruffleObject that knows its PolyglotEngine and wrapping all values returned from the engine by it, so it is always clear into which engine context an object belongs.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22173
diff
changeset
|
1243 assertSame(msg, unExpected, unAction); |
7abcbeb12d08
Creating a TruffleObject that knows its PolyglotEngine and wrapping all values returned from the engine by it, so it is always clear into which engine context an object belongs.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22173
diff
changeset
|
1244 } |
7abcbeb12d08
Creating a TruffleObject that knows its PolyglotEngine and wrapping all values returned from the engine by it, so it is always clear into which engine context an object belongs.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22173
diff
changeset
|
1245 |
7abcbeb12d08
Creating a TruffleObject that knows its PolyglotEngine and wrapping all values returned from the engine by it, so it is always clear into which engine context an object belongs.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22173
diff
changeset
|
1246 private static Object unwrapTruffleObject(Object obj) { |
7abcbeb12d08
Creating a TruffleObject that knows its PolyglotEngine and wrapping all values returned from the engine by it, so it is always clear into which engine context an object belongs.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22173
diff
changeset
|
1247 try { |
7abcbeb12d08
Creating a TruffleObject that knows its PolyglotEngine and wrapping all values returned from the engine by it, so it is always clear into which engine context an object belongs.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22173
diff
changeset
|
1248 if (obj instanceof TruffleObject) { |
7abcbeb12d08
Creating a TruffleObject that knows its PolyglotEngine and wrapping all values returned from the engine by it, so it is always clear into which engine context an object belongs.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22173
diff
changeset
|
1249 Class<?> eto = Class.forName("com.oracle.truffle.api.vm.EngineTruffleObject"); |
7abcbeb12d08
Creating a TruffleObject that knows its PolyglotEngine and wrapping all values returned from the engine by it, so it is always clear into which engine context an object belongs.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22173
diff
changeset
|
1250 if (eto.isInstance(obj)) { |
7abcbeb12d08
Creating a TruffleObject that knows its PolyglotEngine and wrapping all values returned from the engine by it, so it is always clear into which engine context an object belongs.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22173
diff
changeset
|
1251 final Field field = eto.getDeclaredField("delegate"); |
7abcbeb12d08
Creating a TruffleObject that knows its PolyglotEngine and wrapping all values returned from the engine by it, so it is always clear into which engine context an object belongs.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22173
diff
changeset
|
1252 field.setAccessible(true); |
7abcbeb12d08
Creating a TruffleObject that knows its PolyglotEngine and wrapping all values returned from the engine by it, so it is always clear into which engine context an object belongs.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22173
diff
changeset
|
1253 return field.get(obj); |
7abcbeb12d08
Creating a TruffleObject that knows its PolyglotEngine and wrapping all values returned from the engine by it, so it is always clear into which engine context an object belongs.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22173
diff
changeset
|
1254 } |
7abcbeb12d08
Creating a TruffleObject that knows its PolyglotEngine and wrapping all values returned from the engine by it, so it is always clear into which engine context an object belongs.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22173
diff
changeset
|
1255 } |
7abcbeb12d08
Creating a TruffleObject that knows its PolyglotEngine and wrapping all values returned from the engine by it, so it is always clear into which engine context an object belongs.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22173
diff
changeset
|
1256 return obj; |
7abcbeb12d08
Creating a TruffleObject that knows its PolyglotEngine and wrapping all values returned from the engine by it, so it is always clear into which engine context an object belongs.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22173
diff
changeset
|
1257 } catch (Exception ex) { |
7abcbeb12d08
Creating a TruffleObject that knows its PolyglotEngine and wrapping all values returned from the engine by it, so it is always clear into which engine context an object belongs.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22173
diff
changeset
|
1258 throw new IllegalStateException(ex); |
7abcbeb12d08
Creating a TruffleObject that knows its PolyglotEngine and wrapping all values returned from the engine by it, so it is always clear into which engine context an object belongs.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22173
diff
changeset
|
1259 } |
7abcbeb12d08
Creating a TruffleObject that knows its PolyglotEngine and wrapping all values returned from the engine by it, so it is always clear into which engine context an object belongs.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22173
diff
changeset
|
1260 } |
7abcbeb12d08
Creating a TruffleObject that knows its PolyglotEngine and wrapping all values returned from the engine by it, so it is always clear into which engine context an object belongs.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22173
diff
changeset
|
1261 |
22135
e70b20f4bb00
Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22121
diff
changeset
|
1262 interface CompoundObject { |
e70b20f4bb00
Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22121
diff
changeset
|
1263 Number fourtyTwo(); |
e70b20f4bb00
Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22121
diff
changeset
|
1264 |
e70b20f4bb00
Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22121
diff
changeset
|
1265 Number plus(int x, int y); |
e70b20f4bb00
Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22121
diff
changeset
|
1266 |
e70b20f4bb00
Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22121
diff
changeset
|
1267 Object returnsNull(); |
e70b20f4bb00
Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22121
diff
changeset
|
1268 |
e70b20f4bb00
Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22121
diff
changeset
|
1269 CompoundObject returnsThis(); |
e70b20f4bb00
Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22121
diff
changeset
|
1270 } |
22523
6ab540203853
Expanding TCK to cover reading and writing of object properties with various primitive types
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22496
diff
changeset
|
1271 |
6ab540203853
Expanding TCK to cover reading and writing of object properties with various primitive types
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22496
diff
changeset
|
1272 interface ValuesObject { |
6ab540203853
Expanding TCK to cover reading and writing of object properties with various primitive types
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22496
diff
changeset
|
1273 byte byteValue(); |
6ab540203853
Expanding TCK to cover reading and writing of object properties with various primitive types
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22496
diff
changeset
|
1274 |
6ab540203853
Expanding TCK to cover reading and writing of object properties with various primitive types
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22496
diff
changeset
|
1275 @MethodMessage(message = "WRITE") |
6ab540203853
Expanding TCK to cover reading and writing of object properties with various primitive types
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22496
diff
changeset
|
1276 void byteValue(byte v); |
6ab540203853
Expanding TCK to cover reading and writing of object properties with various primitive types
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22496
diff
changeset
|
1277 |
6ab540203853
Expanding TCK to cover reading and writing of object properties with various primitive types
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22496
diff
changeset
|
1278 short shortValue(); |
6ab540203853
Expanding TCK to cover reading and writing of object properties with various primitive types
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22496
diff
changeset
|
1279 |
6ab540203853
Expanding TCK to cover reading and writing of object properties with various primitive types
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22496
diff
changeset
|
1280 @MethodMessage(message = "WRITE") |
6ab540203853
Expanding TCK to cover reading and writing of object properties with various primitive types
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22496
diff
changeset
|
1281 void shortValue(short v); |
6ab540203853
Expanding TCK to cover reading and writing of object properties with various primitive types
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22496
diff
changeset
|
1282 |
6ab540203853
Expanding TCK to cover reading and writing of object properties with various primitive types
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22496
diff
changeset
|
1283 int intValue(); |
6ab540203853
Expanding TCK to cover reading and writing of object properties with various primitive types
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22496
diff
changeset
|
1284 |
6ab540203853
Expanding TCK to cover reading and writing of object properties with various primitive types
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22496
diff
changeset
|
1285 @MethodMessage(message = "WRITE") |
6ab540203853
Expanding TCK to cover reading and writing of object properties with various primitive types
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22496
diff
changeset
|
1286 void intValue(int v); |
6ab540203853
Expanding TCK to cover reading and writing of object properties with various primitive types
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22496
diff
changeset
|
1287 |
6ab540203853
Expanding TCK to cover reading and writing of object properties with various primitive types
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22496
diff
changeset
|
1288 long longValue(); |
6ab540203853
Expanding TCK to cover reading and writing of object properties with various primitive types
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22496
diff
changeset
|
1289 |
6ab540203853
Expanding TCK to cover reading and writing of object properties with various primitive types
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22496
diff
changeset
|
1290 @MethodMessage(message = "WRITE") |
6ab540203853
Expanding TCK to cover reading and writing of object properties with various primitive types
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22496
diff
changeset
|
1291 void longValue(long v); |
6ab540203853
Expanding TCK to cover reading and writing of object properties with various primitive types
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22496
diff
changeset
|
1292 |
6ab540203853
Expanding TCK to cover reading and writing of object properties with various primitive types
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22496
diff
changeset
|
1293 float floatValue(); |
6ab540203853
Expanding TCK to cover reading and writing of object properties with various primitive types
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22496
diff
changeset
|
1294 |
6ab540203853
Expanding TCK to cover reading and writing of object properties with various primitive types
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22496
diff
changeset
|
1295 @MethodMessage(message = "WRITE") |
6ab540203853
Expanding TCK to cover reading and writing of object properties with various primitive types
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22496
diff
changeset
|
1296 void floatValue(float v); |
6ab540203853
Expanding TCK to cover reading and writing of object properties with various primitive types
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22496
diff
changeset
|
1297 |
6ab540203853
Expanding TCK to cover reading and writing of object properties with various primitive types
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22496
diff
changeset
|
1298 double doubleValue(); |
6ab540203853
Expanding TCK to cover reading and writing of object properties with various primitive types
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22496
diff
changeset
|
1299 |
6ab540203853
Expanding TCK to cover reading and writing of object properties with various primitive types
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22496
diff
changeset
|
1300 @MethodMessage(message = "WRITE") |
6ab540203853
Expanding TCK to cover reading and writing of object properties with various primitive types
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22496
diff
changeset
|
1301 void doubleValue(double v); |
6ab540203853
Expanding TCK to cover reading and writing of object properties with various primitive types
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22496
diff
changeset
|
1302 |
6ab540203853
Expanding TCK to cover reading and writing of object properties with various primitive types
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22496
diff
changeset
|
1303 char charValue(); |
6ab540203853
Expanding TCK to cover reading and writing of object properties with various primitive types
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22496
diff
changeset
|
1304 |
6ab540203853
Expanding TCK to cover reading and writing of object properties with various primitive types
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22496
diff
changeset
|
1305 @MethodMessage(message = "WRITE") |
6ab540203853
Expanding TCK to cover reading and writing of object properties with various primitive types
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22496
diff
changeset
|
1306 void charValue(char v); |
6ab540203853
Expanding TCK to cover reading and writing of object properties with various primitive types
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22496
diff
changeset
|
1307 |
6ab540203853
Expanding TCK to cover reading and writing of object properties with various primitive types
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22496
diff
changeset
|
1308 boolean booleanValue(); |
6ab540203853
Expanding TCK to cover reading and writing of object properties with various primitive types
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22496
diff
changeset
|
1309 |
6ab540203853
Expanding TCK to cover reading and writing of object properties with various primitive types
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22496
diff
changeset
|
1310 @MethodMessage(message = "WRITE") |
6ab540203853
Expanding TCK to cover reading and writing of object properties with various primitive types
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22496
diff
changeset
|
1311 void booleanValue(boolean v); |
6ab540203853
Expanding TCK to cover reading and writing of object properties with various primitive types
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22496
diff
changeset
|
1312 } |
21938
0a6e10379b9b
Keeping only Truffle-related modules in this repository
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
1313 } |