function Alpha() { this.onion = 'onion'; function Beta() { alert(this.onion); } Beta.call(this); } var alpha1 = new Alpha(); // Alerts 'onion'
function Alpha() { this.onion = 'onion'; var Beta = function () { alert(this.onion); }.bind(this); Beta(); } var alpha1 = new Alpha(); // Alerts 'onion'
@Override protected SceneGraphObject createNode() { return new Alpha(); } }
Alpha alpha = spy(new Alpha()); String result = foo.bar(alpha, baz); verify(alpha).get();
Gamma test = new Alpha(); // compilation error // or... Gamma test = new Beta(); // compilation error
public class AlphaDemo { public static void main(String arg[]) { Alpha xxNewLetter = new Alpha('A'); System.out.println(xxNewLetter); } }
Alpha newA1 = new Alpha(1.0, "a", null); // oldAlpha == null so we only newA1.y = "a" Alpha newA2 = new Alpha(2.0, "b", newA1); // oldAlpha is newA1 => newA1.y = "b"+"a"; newA2.y = "b" Alpha newA3 = new Alpha(3.0, "c", newA2); // oldAlpha is newA2 => newA2.y = "c"+"b", newA3.y = "c"; newA1.y = "ba" (still) System.out.println(newA1.y + newA2.y + newA3.y); // newA1.y = "ba", newA2.y = "cb", newA3.y = "c"
Alpha newA1 = new Alpha(1.0, "a", null); //no old Alpha Alpha newA2 = new Alpha(2.0, "b", newA1); // newA1.y = bc as newA1 is Old alpha Alpha newA3 = new Alpha(3.0, "c", newA2); // newA2.y = cb as newA2 is Old alpha
public static void main(String[] args) { Beta3 varobjBeta; varobjBeta = new Beta3(); varobjBeta.isiB(10); Alpha varobjAlpha; varobjAlpha = new Alpha(); varobjAlpha.info(varobjBeta); }
@Test public void testBar_callsBarWithXray() throws Exception { Baz baz = new Baz(); //POJOs Alpha alpha = new Alpha(); alpha.set(new Xray()); Foo stub = PowerMockito.spy(new Foo()); Method m = MemberMatcher.method(Foo.class, "bar", Xray.class, Baz.class); PowerMockito.doReturn("ok") .when(stub, m ) .withArguments(Matchers.any(Xray.class), Matchers.any(Baz.class)); stub.bar(alpha, baz); PowerMockito.verifyPrivate(stub, Mockito.times(1)).invoke("bar", Matchers.any(Xray.class), Matchers.any(Baz.class)); // Mockito's equivalent for a public method: verify(stub, times(1)).bar(any(Xray.class), any(Baz.class)); } output is : public bar ok
@RunWith(PowerMockRunner.class) //@PrepareOnlyThisForTest(Foo.class) // we aren't looking at the byte code, I think public class FooTest { @Test public void testBar_callsBarWithXray() throws Exception { Baz baz = new Baz(); //POJOs Alpha alpha = new Alpha(); alpha.set(new Xray()); Foo foo = new Foo(); Foo stub = PowerMockito.spy(foo); // using Mockito, as it's neither final nor "not spyable" // NPE at org.powermock.api.mockito.internal.expectation.PowerMockitoStubberImpl.addAnswersForStubbing(PowerMockitoStubberImpl.java:67) PowerMockito.doReturn("ok").when(stub, "bar", Matchers.any(Xray.class), Matchers.any(Baz.class)); String res = stub.bar(alpha, baz); Assert.assertEquals("ok", res); //Testing if bar(Xray, Baz) was called by bar(Alpha, Baz) PowerMockito.verifyPrivate(stub).invoke("bar", Matchers.any(Xray.class), Matchers.any(Baz.class)); // Mockito's equivalent for a public method: verify(stub, times(1)).bar(any(Xray.class), any(Baz.class)); } }
public void testBar_callsBarWithXray() throws Exception { Baz baz = new Baz(); //POJOs Alpha alpha = new Alpha(); alpha.set(new Xray());
Alpha theAlpha = new Alpha(-1, Alpha.INCREASING_ENABLE, 0, 0, (long)(1000f * totalTime), 0, 0, 0, 0, 0);
/** * Creates a SwitchValueInterpolator which is used to switch between * the objects specified for the sequence. This is done for files * that end in "000", meaning that there are a sequence of files * with that same base name that should specify every frame of a * sequence for an object. The Switch node is used to hold all of the * files and the Switch Behavior node is used to activate switching * at the right time and to the right object. */ private void createSwitchBehavior(Switch target) { int loopCount = -1; float animTime = 1000.0f * totalTime * (float)(target.numChildren())/(float)totalFrames; float startTime = 1000f * totalTime * (float)startFrame/(float)totalFrames; Alpha theAlpha = new Alpha(-1, (long)startTime, 0, (long)animTime, 0, 0); SwitchValueInterpolator b=new SwitchValueInterpolator(theAlpha,target); behaviors = b; BoundingSphere bounds = new BoundingSphere(new Point3d(0.0,0.0,0.0), 1000000.0); b.setSchedulingBounds(bounds); target.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); target.addChild(behaviors); }
animation = new Alpha(-1, 4000); animation.pause(); animation.setStartTime(System.currentTimeMillis());
/** * This internal method returns a clone of the Alpha * * @return a duplicate of this Alpha */ Alpha cloneAlpha() { Alpha a = new Alpha(); a.setStartTime(getStartTime()); a.setLoopCount(getLoopCount()); a.setMode(getMode()); a.setTriggerTime(getTriggerTime()); a.setPhaseDelayDuration(getPhaseDelayDuration()); a.setIncreasingAlphaDuration(getIncreasingAlphaDuration()); a.setIncreasingAlphaRampDuration(getIncreasingAlphaRampDuration()); a.setAlphaAtOneDuration(getAlphaAtOneDuration()); a.setDecreasingAlphaDuration(getDecreasingAlphaDuration()); a.setDecreasingAlphaRampDuration(getDecreasingAlphaRampDuration()); a.setAlphaAtZeroDuration(getAlphaAtZeroDuration()); return a; }
Alpha rotationAlpha = new Alpha(-1, 4000);
alphaAtOne = (long)(1000.0*totalTime - animTime); Alpha theAlpha = new Alpha(loopCount, Alpha.INCREASING_ENABLE, 0, 0, (long)animTime, 0, alphaAtOne, 0, 0, 0);
tg.addChild(sig); final Alpha alpha = new Alpha(); alpha.setStartTime(System.currentTimeMillis()); alpha.setMode(Alpha.DECREASING_ENABLE | Alpha.INCREASING_ENABLE);
alphaAtOne = (long)(1000.0*totalTime - animTime); Alpha theAlpha = new Alpha(loopCount, Alpha.INCREASING_ENABLE, 0, 0, (long)animTime, 0, alphaAtOne, 0, 0, 0);