blob: 72d57012f49442a6194b9f4979a091df743e5582 [file] [log] [blame]
package org.eclipse.debug.jdi.tests;
/**********************************************************************
Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
This file is made available under the terms of the Common Public License v1.0
which accompanies this distribution, and is available at
http://www.eclipse.org/legal/cpl-v10.html
**********************************************************************/
import com.sun.jdi.AbsentInformationException;
import com.sun.jdi.ClassNotLoadedException;
import com.sun.jdi.LocalVariable;
/**
* Tests for JDI com.sun.jdi.LocalVariable.
*/
public class LocalVariableTest extends AbstractJDITest {
private LocalVariable fVar;
/**
* Creates a new test.
*/
public LocalVariableTest() {
super();
}
/**
* Init the fields that are used by this test only.
*/
public void localSetUp() {
// Wait for the program to be ready
waitUntilReady();
// Get local variable "t" in the frame running MainClass.run()
fVar = getLocalVariable();
}
/**
* Run all tests and output to standard output.
*/
public static void main(java.lang.String[] args) {
new LocalVariableTest().runSuite(args);
}
/**
* Gets the name of the test case.
*/
public String getName() {
return "com.sun.jdi.LocalVariable";
}
/**
* Test JDI equals() and hashCode().
*/
public void testJDIEquality() {
assertTrue("1", fVar.equals(fVar));
LocalVariable other = null;
try {
other = getFrame(RUN_FRAME_OFFSET).visibleVariableByName("o");
} catch (AbsentInformationException e) {
assertTrue("2", false);
}
assertTrue("3", !fVar.equals(other));
assertTrue("4", !fVar.equals(new Object()));
assertTrue("5", !fVar.equals(null));
assertTrue("6", fVar.hashCode() != other.hashCode());
}
/**
* Test JDI isArgument().
*/
public void testJDIIsArgument() {
assertTrue("1", !fVar.isArgument());
}
/**
* Test JDI isVisible(StackFrame).
*/
public void testJDIIsVisible() {
assertTrue("1", fVar.isVisible(getFrame(RUN_FRAME_OFFSET)));
boolean gotException = false;
try {
fVar.isVisible(getFrame(0));
} catch (IllegalArgumentException e) {
gotException = true;
}
assertTrue("2", gotException);
}
/**
* Test JDI name().
*/
public void testJDIName() {
assertEquals("1", "t", fVar.name());
}
/**
* Test JDI signature().
*/
public void testJDISignature() {
assertEquals("1", "Ljava/lang/Thread;", fVar.signature());
}
/**
* Test JDI type().
*/
public void testJDIType() {
try {
assertEquals(
"1",
fVM.classesByName("java.lang.Thread").get(0),
fVar.type());
} catch (ClassNotLoadedException e) {
assertTrue("2", false);
}
}
/**
* Test JDI typeName().
*/
public void testJDITypeName() {
assertEquals("1", "java.lang.Thread", fVar.typeName());
}
}