Search in sources :

Example 11 with OptionDescriptor

use of org.graalvm.options.OptionDescriptor in project graal by oracle.

the class OptionProcessorTest method testTestLang.

@Test
public void testTestLang() {
    Engine engine = Engine.create();
    OptionDescriptors descriptors = engine.getLanguages().get("optiontestlang1").getOptions();
    OptionDescriptor descriptor;
    OptionDescriptor descriptor1;
    OptionDescriptor descriptor2;
    descriptor1 = descriptor = descriptors.get("optiontestlang1.StringOption1");
    assertNotNull(descriptor);
    assertTrue(descriptor.isDeprecated());
    assertSame(OptionCategory.USER, descriptor.getCategory());
    assertEquals("StringOption1 help", descriptor.getHelp());
    assertSame(OptionTestLang1.StringOption1, descriptor.getKey());
    descriptor2 = descriptor = descriptors.get("optiontestlang1.StringOption2");
    assertNotNull(descriptor);
    assertEquals("StringOption2 help", descriptor.getHelp());
    assertFalse(descriptor.isDeprecated());
    assertSame(OptionCategory.EXPERT, descriptor.getCategory());
    assertSame(OptionTestLang1.StringOption2, descriptor.getKey());
    Iterator<OptionDescriptor> iterator = descriptors.iterator();
    assertTrue(iterator.hasNext());
    assertEquals(descriptor1, iterator.next());
    assertTrue(iterator.hasNext());
    assertEquals(descriptor2, iterator.next());
    assertFalse(iterator.hasNext());
    assertNull(descriptors.get("optiontestlang1.StringOption3"));
}
Also used : OptionDescriptor(org.graalvm.options.OptionDescriptor) OptionDescriptors(org.graalvm.options.OptionDescriptors) Engine(org.graalvm.polyglot.Engine) Test(org.junit.Test)

Example 12 with OptionDescriptor

use of org.graalvm.options.OptionDescriptor in project graal by oracle.

the class EngineAPITest method getLanguageOptions.

@Test
public void getLanguageOptions() {
    Engine engine = Engine.create();
    Language language = engine.getLanguages().get(EngineAPITestLanguage.ID);
    OptionDescriptor descriptor1 = language.getOptions().get(EngineAPITestLanguage.Option1_NAME);
    OptionDescriptor descriptor2 = language.getOptions().get(EngineAPITestLanguage.Option2_NAME);
    OptionDescriptor descriptor3 = language.getOptions().get(EngineAPITestLanguage.Option3_NAME);
    assertSame(EngineAPITestLanguage.Option1, descriptor1.getKey());
    assertEquals(EngineAPITestLanguage.Option1_NAME, descriptor1.getName());
    assertEquals(EngineAPITestLanguage.Option1_CATEGORY, descriptor1.getCategory());
    assertEquals(EngineAPITestLanguage.Option1_DEPRECATED, descriptor1.isDeprecated());
    assertEquals(EngineAPITestLanguage.Option1_HELP, descriptor1.getHelp());
    assertSame(EngineAPITestLanguage.Option2, descriptor2.getKey());
    assertEquals(EngineAPITestLanguage.Option2_NAME, descriptor2.getName());
    assertEquals(EngineAPITestLanguage.Option2_CATEGORY, descriptor2.getCategory());
    assertEquals(EngineAPITestLanguage.Option2_DEPRECATED, descriptor2.isDeprecated());
    assertEquals(EngineAPITestLanguage.Option2_HELP, descriptor2.getHelp());
    assertSame(EngineAPITestLanguage.Option3, descriptor3.getKey());
    assertEquals(EngineAPITestLanguage.Option3_NAME, descriptor3.getName());
    assertEquals(EngineAPITestLanguage.Option3_CATEGORY, descriptor3.getCategory());
    assertEquals(EngineAPITestLanguage.Option3_DEPRECATED, descriptor3.isDeprecated());
    assertEquals(EngineAPITestLanguage.Option3_HELP, descriptor3.getHelp());
    engine.close();
}
Also used : Language(org.graalvm.polyglot.Language) OptionDescriptor(org.graalvm.options.OptionDescriptor) Engine(org.graalvm.polyglot.Engine) Test(org.junit.Test)

Aggregations

OptionDescriptor (org.graalvm.options.OptionDescriptor)12 Engine (org.graalvm.polyglot.Engine)5 Test (org.junit.Test)5 ArrayList (java.util.ArrayList)4 OptionDescriptors (org.graalvm.options.OptionDescriptors)3 Language (org.graalvm.polyglot.Language)3 HashMap (java.util.HashMap)2 List (java.util.List)2 Instrument (org.graalvm.polyglot.Instrument)2 TruffleContext (com.oracle.truffle.api.TruffleContext)1 LanguageContext (com.oracle.truffle.api.test.polyglot.LanguageSPITestLanguage.LanguageContext)1 Formatter (java.util.Formatter)1 Iterator (java.util.Iterator)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 OptionCategory (org.graalvm.options.OptionCategory)1 OptionKey (org.graalvm.options.OptionKey)1 Context (org.graalvm.polyglot.Context)1