Mercurial > hg > truffle
comparison truffle/com.oracle.truffle.tck/src/com/oracle/truffle/tck/TruffleTCK.java @ 22537:c6f1f40a87ba
fix typo
author | Andreas Woess <andreas.woess@oracle.com> |
---|---|
date | Fri, 08 Jan 2016 22:22:24 +0100 |
parents | 89db2519ef18 |
children | e77bcc4e4af6 |
comparison
equal
deleted
inserted
replaced
22536:21f48bc8a535 | 22537:c6f1f40a87ba |
---|---|
58 /** | 58 /** |
59 * Test compatibility kit (the <em>TCK</em>) is a collection of tests to certify your | 59 * Test compatibility kit (the <em>TCK</em>) is a collection of tests to certify your |
60 * {@link TruffleLanguage language implementation} compliance. If you want your language to be | 60 * {@link TruffleLanguage language implementation} compliance. If you want your language to be |
61 * compliant with most recent requirements of the Truffle infrastructure and tooling, subclass, | 61 * compliant with most recent requirements of the Truffle infrastructure and tooling, subclass, |
62 * implement <b>protected</b> methods and include in your test suite: | 62 * implement <b>protected</b> methods and include in your test suite: |
63 * | 63 * |
64 * <pre> | 64 * <pre> |
65 * <b>public class</b> MyLanguageTCKTest <b>extends</b> {@link TruffleTCK} { | 65 * <b>public class</b> MyLanguageTCKTest <b>extends</b> {@link TruffleTCK} { |
66 * {@link Override @Override} | 66 * {@link Override @Override} |
67 * <b>protected</b> {@link PolyglotEngine} {@link #prepareVM() prepareVM}() { | 67 * <b>protected</b> {@link PolyglotEngine} {@link #prepareVM() prepareVM}() { |
68 * <em>// create the engine</em> | 68 * <em>// create the engine</em> |
75 * } | 75 * } |
76 * | 76 * |
77 * <em>// and so on...</em> | 77 * <em>// and so on...</em> |
78 * } | 78 * } |
79 * </pre> | 79 * </pre> |
80 * | 80 * |
81 * The <em>TCK</em> is carefully designed to accommodate differences between languages. The | 81 * The <em>TCK</em> is carefully designed to accommodate differences between languages. The |
82 * <em>TCK</em> doesn't dictate what object your language is using to represent {@link Number | 82 * <em>TCK</em> doesn't dictate what object your language is using to represent {@link Number |
83 * numbers} or {@link String strings} internally. The <em>TCK</em> doesn't prescribe the precise | 83 * numbers} or {@link String strings} internally. The <em>TCK</em> doesn't prescribe the precise |
84 * type of values returned from your | 84 * type of values returned from your |
85 * {@link PolyglotEngine#eval(com.oracle.truffle.api.source.Source) language evaluations}. The tests | 85 * {@link PolyglotEngine#eval(com.oracle.truffle.api.source.Source) language evaluations}. The tests |
87 * of {@link Number} or be {@link Message#UNBOX convertible} to a {@link Number} and keeps | 87 * of {@link Number} or be {@link Message#UNBOX convertible} to a {@link Number} and keeps |
88 * sufficient level of precision. Similarly for {@link String strings}. As such the tests in the | 88 * sufficient level of precision. Similarly for {@link String strings}. As such the tests in the |
89 * <em>TCK</em> should be applicable to wide range of languages. Should there be a test that cannot | 89 * <em>TCK</em> should be applicable to wide range of languages. Should there be a test that cannot |
90 * be implemented in your language, it can be suppressed by overriding its test method and doing | 90 * be implemented in your language, it can be suppressed by overriding its test method and doing |
91 * nothing: | 91 * nothing: |
92 * | 92 * |
93 * <pre> | 93 * <pre> |
94 * {@link Override @Override} | 94 * {@link Override @Override} |
95 * <b>public void</b> {@link #testFortyTwo() testFortyTwo}() { | 95 * <b>public void</b> {@link #testFortyTwo() testFortyTwo}() { |
96 * <em>// do nothing</em> | 96 * <em>// do nothing</em> |
97 * } | 97 * } |
859 if (globalObjectFunction == null) { | 859 if (globalObjectFunction == null) { |
860 return; | 860 return; |
861 } | 861 } |
862 | 862 |
863 Language language = vm().getLanguages().get(mimeType()); | 863 Language language = vm().getLanguages().get(mimeType()); |
864 assertNotNull("Langugage for " + mimeType() + " found", language); | 864 assertNotNull("Language for " + mimeType() + " found", language); |
865 | 865 |
866 PolyglotEngine.Value function = vm().findGlobalSymbol(globalObjectFunction); | 866 PolyglotEngine.Value function = vm().findGlobalSymbol(globalObjectFunction); |
867 Object global = function.execute().get(); | 867 Object global = function.execute().get(); |
868 assertEquals("Global from the language same with Java obtained one", language.getGlobalObject().get(), global); | 868 assertEquals("Global from the language same with Java obtained one", language.getGlobalObject().get(), global); |
869 } | 869 } |
870 | 870 |
871 @Test | 871 @Test |
872 public void testEvaluateSource() throws Exception { | 872 public void testEvaluateSource() throws Exception { |
873 Language language = vm().getLanguages().get(mimeType()); | 873 Language language = vm().getLanguages().get(mimeType()); |
874 assertNotNull("Langugage for " + mimeType() + " found", language); | 874 assertNotNull("Language for " + mimeType() + " found", language); |
875 | 875 |
876 PolyglotEngine.Value function = vm().findGlobalSymbol(evaluateSource()); | 876 PolyglotEngine.Value function = vm().findGlobalSymbol(evaluateSource()); |
877 assertNotNull(evaluateSource() + " found", function); | 877 assertNotNull(evaluateSource() + " found", function); |
878 | 878 |
879 double expect = Math.floor(RANDOM.nextDouble() * 100000.0) / 10.0; | 879 double expect = Math.floor(RANDOM.nextDouble() * 100000.0) / 10.0; |