Commit 27c20c3d authored by Stephanie Gawroriski's avatar Stephanie Gawroriski
Browse files

Correct Object.clone() returning this and not the new array (add test)

parent b6ecbcfa
......@@ -54,7 +54,9 @@ More detailed changes:
* Corrected bug in `__CanSetPrintStream__` where if it were set to itself
then it could lead to infinite recursion, instead if this kind of
stream is attempted to be set it will use the target.
* Corrected `java.util.Object.equals()` not correctly checking equality
* Corrected `java.lang.Object.clone()` to return the new copy of the array
when cloning and not the original.
* Corrected `java.util.Objects.equals()` not correctly checking equality
on two objects.
* Fallback encoding is now UTF-8 and not ISO-8859-1.
* If the name of the requested resource is blank, ignore it.
......
result: true
thrown: NoExceptionThrown
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
// Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------
package lang;
import java.util.Arrays;
import net.multiphasicapps.tac.TestBoolean;
/**
* This tests that array cloning is correct.
*
* @since 2019/12/25
*/
public class TestArrayClone
extends TestBoolean
{
/**
* {@inheritDoc}
* @since 2019/12/25
*/
@Override
public final boolean test()
{
// Setup new array
int[] array = new int[12];
for (int i = 0; i < 12; i++)
array[i] = i;
int[] cloned = array.clone();
return Arrays.equals(array, cloned) && array != cloned;
}
}
......@@ -65,10 +65,10 @@ public class Object
System.arraycopy(this, 0, dest, 0, len);
// This array was cloned
return this;
return dest;
}
// {@squirreljme.error ZZ1d This object does not support being clone.}
// {@squirreljme.error ZZ1d This object does not support being cloned.}
throw new CloneNotSupportedException("ZZ1d");
}
......
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
// Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------
package net.multiphasicapps.tac;
/**
* This is a test which returns a boolean.
*
* @since 2019/12/25
*/
public abstract class TestBoolean
extends __CoreTest__
{
/**
* Runs the specified test.
*
* @return The result.
* @throws Throwable On any thrown exception.
* @since 2019/12/25
*/
public abstract boolean test()
throws Throwable;
/**
* {@inheritDoc}
* @since 2019/12/25
*/
@Override
final Object __runTest(Object... __args)
throws Throwable
{
// {@squirreljme.error BU0f Test does not take any parameters.}
if (__args.length != 0)
throw new InvalidTestParameterException("BU0e");
// Run the test
return Boolean.valueOf(this.test());
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment