public void testHasArrayInitializerAndFunction() throws ClassNotFoundException { IGosuClassInternal gsClass = (IGosuClassInternal) TypeSystem.getByFullName( "gw.internal.gosu.parser.classTests.gwtest.varTests.HasArrayInitializerAndFunction"); assertTrue(gsClass.isValid()); }
public void testUnspecifiedScriptabilityDefaultsToScriptableAll() { IGosuClassInternal gosuClass = (IGosuClassInternal) TypeSystem.getByFullName( "gw.internal.gosu.parser.annotation.gwtest.annotation.scriptable.NoScriptable"); for (IAttributedFeatureInfo feature : gosuClass.getTypeInfo().getProperties()) { assertTrue(feature.isVisible(ScriptabilityModifiers.SCRIPTABLE)); } for (IAttributedFeatureInfo feature : gosuClass.getTypeInfo().getConstructors()) { assertTrue(feature.isVisible(ScriptabilityModifiers.SCRIPTABLE)); } for (IAttributedFeatureInfo feature : gosuClass.getTypeInfo().getMethods()) { assertTrue(feature.isVisible(ScriptabilityModifiers.SCRIPTABLE)); } }
private void addTypeVarsFromEnclosingFunctions( IGosuClassInternal gsClass, List<IRType> parameters) { while (gsClass.isAnonymous()) { IDynamicFunctionSymbol dfs = AbstractElementTransformer.getEnclosingDFS(gsClass); if (dfs == null) { break; } addTypeVariableParameters( parameters, AbstractElementTransformer.getTypeVarsForDFS(dfs).size()); gsClass = (IGosuClassInternal) dfs.getGosuClass(); } }
public void testScopedVarsAreScopedByThread() throws Throwable { final IGosuClassInternal gosuClass = (IGosuClassInternal) TypeSystem.getByFullName( "gw.internal.gosu.parser.classTests.gwtest.varTests.VarScope1"); gosuClass.getTypeInfo().getProperty("_staticVar").getAccessor().setValue(null, "static"); gosuClass.getTypeInfo().getProperty("_sessionVar").getAccessor().setValue(null, "session"); gosuClass.getTypeInfo().getProperty("_requestVar").getAccessor().setValue(null, "request"); gosuClass.getTypeInfo().getProperty("_appVar").getAccessor().setValue(null, "app"); assertEquals( "static", gosuClass.getTypeInfo().getProperty("_staticVar").getAccessor().getValue(null)); assertEquals( "session", gosuClass.getTypeInfo().getProperty("_sessionVar").getAccessor().getValue(null)); assertEquals( "request", gosuClass.getTypeInfo().getProperty("_requestVar").getAccessor().getValue(null)); assertEquals( "app", gosuClass.getTypeInfo().getProperty("_appVar").getAccessor().getValue(null)); final Throwable e[] = new Throwable[1]; Thread t = new Thread( new Runnable() { public void run() { try { assertEquals( "static", gosuClass .getTypeInfo() .getProperty("_staticVar") .getAccessor() .getValue(null)); // // assertNull(gosuClass.getTypeInfo().getProperty("_sessionVar").getAccessor().getValue(null)); // assertNull( // gosuClass.getTypeInfo().getProperty("_requestVar").getAccessor().getValue(null)); // assertEquals("app", // gosuClass.getTypeInfo().getProperty("_appVar").getAccessor().getValue(null)); } catch (Throwable t) { e[0] = t; } } }); t.start(); t.join(5000); if (e[0] != null) { throw e[0]; } }
public void testScopedVarsDoNotBleedAcrossTwoClassIfPropertiesAreSame() throws Throwable { final IGosuClassInternal gosuClass = (IGosuClassInternal) TypeSystem.getByFullName( "gw.internal.gosu.parser.classTests.gwtest.varTests.VarScope1"); gosuClass.getTypeInfo().getProperty("_staticVar").getAccessor().setValue(null, "static"); gosuClass.getTypeInfo().getProperty("_sessionVar").getAccessor().setValue(null, "session"); gosuClass.getTypeInfo().getProperty("_requestVar").getAccessor().setValue(null, "request"); gosuClass.getTypeInfo().getProperty("_appVar").getAccessor().setValue(null, "app"); assertEquals( "static", gosuClass.getTypeInfo().getProperty("_staticVar").getAccessor().getValue(null)); assertEquals( "session", gosuClass.getTypeInfo().getProperty("_sessionVar").getAccessor().getValue(null)); assertEquals( "request", gosuClass.getTypeInfo().getProperty("_requestVar").getAccessor().getValue(null)); assertEquals( "app", gosuClass.getTypeInfo().getProperty("_appVar").getAccessor().getValue(null)); final IGosuClassInternal gosuClass2 = (IGosuClassInternal) TypeSystem.getByFullName( "gw.internal.gosu.parser.classTests.gwtest.varTests.VarScope2"); gosuClass2.getTypeInfo().getProperty("_staticVar").getAccessor().setValue(null, "static2"); gosuClass2.getTypeInfo().getProperty("_sessionVar").getAccessor().setValue(null, "session2"); gosuClass2.getTypeInfo().getProperty("_requestVar").getAccessor().setValue(null, "request2"); gosuClass2.getTypeInfo().getProperty("_appVar").getAccessor().setValue(null, "app2"); assertEquals( "static2", gosuClass2.getTypeInfo().getProperty("_staticVar").getAccessor().getValue(null)); assertEquals( "session2", gosuClass2.getTypeInfo().getProperty("_sessionVar").getAccessor().getValue(null)); assertEquals( "request2", gosuClass2.getTypeInfo().getProperty("_requestVar").getAccessor().getValue(null)); assertEquals( "app2", gosuClass2.getTypeInfo().getProperty("_appVar").getAccessor().getValue(null)); // Now check the old class assertEquals( "static", gosuClass.getTypeInfo().getProperty("_staticVar").getAccessor().getValue(null)); assertEquals( "session", gosuClass.getTypeInfo().getProperty("_sessionVar").getAccessor().getValue(null)); assertEquals( "request", gosuClass.getTypeInfo().getProperty("_requestVar").getAccessor().getValue(null)); assertEquals( "app", gosuClass.getTypeInfo().getProperty("_appVar").getAccessor().getValue(null)); }