### Question:
MethodState extends BaseState { @Override public String toString() { return toString(true); } MethodState(ExecutionContext context, int registerCount);  MethodState(ExecutionContext context, int registerCount, int parameterCount, int parameterSize);   MethodState(MethodState other, ExecutionContext context); private  MethodState(MethodState parent, ExecutionContext context, TIntSet mutableParameters); void assignExceptionRegister(Throwable exception); void assignParameter(int parameterRegister, HeapItem item); void assignParameter(int parameterRegister, Object value, String type); void assignRegister(int register, HeapItem item); void assignRegister(int register, Object value, String type); void assignRegisterAndUpdateIdentities(int register, HeapItem item); void assignResultRegister(HeapItem item); void assignResultRegister(Object value, String type); void assignReturnRegister(HeapItem item); void assignReturnRegister(Object value, String type); void assignThrowRegister(HeapItem item); int getParameterCount(); int getParameterStart(); @Override MethodState getParent(); MethodLocation getPseudoInstructionReturnInstruction(); HeapItem peekExceptionRegister(); HeapItem peekParameter(int parameterRegister); @Nullable HeapItem peekRegister(int register); HeapItem peekResultRegister(); HeapItem peekReturnRegister(); HeapItem peekThrowRegister(); void pokeRegister(int register, HeapItem item); void pokeRegister(int register, Object value, String type); HeapItem readRegister(int register); HeapItem readResultRegister(); HeapItem readReturnRegister(); void setPseudoInstructionReturnLocation(MethodLocation location); @Override String toString(); String toString(boolean onlyPeekCachedRegisters); boolean wasRegisterRead(int register); static final int ResultRegister; static final int ReturnRegister; static final int ReturnAddressRegister; static final int ThrowRegister; static final int ExceptionRegister; static final String MUTABLE_PARAMETER_HEAP; static final String METHOD_HEAP; }### Answer:
@Test public void hasExpectedToString() { ExecutionGraph graph = VMTester.execute(CLASS_NAME, "simpleLoop()V"); ExecutionNode node = graph.getRoot(); MethodState state = node.getContext().getMethodState(); String expected = "params: 0, locals: 2\nv0: type=I, value=0"; assertEquals(expected, state.toString()); }
@Test public void toStringHandlesNullRegisterValuesWhenPeekingAllRegisters() { ExecutionGraph graph = VMTester.execute(CLASS_NAME, "simpleLoop()V"); ExecutionNode node = graph.getRoot(); MethodState state = node.getContext().getMethodState(); String expected = "params: 0, locals: 2\nv0: type=I, value=0\nv1: null"; assertEquals(expected, state.toString(false)); }