jaroslav@355: /** jaroslav@355: * Back 2 Browser Bytecode Translator jaroslav@355: * Copyright (C) 2012 Jaroslav Tulach jaroslav@355: * jaroslav@355: * This program is free software: you can redistribute it and/or modify jaroslav@355: * it under the terms of the GNU General Public License as published by jaroslav@355: * the Free Software Foundation, version 2 of the License. jaroslav@355: * jaroslav@355: * This program is distributed in the hope that it will be useful, jaroslav@355: * but WITHOUT ANY WARRANTY; without even the implied warranty of jaroslav@355: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the jaroslav@355: * GNU General Public License for more details. jaroslav@355: * jaroslav@355: * You should have received a copy of the GNU General Public License jaroslav@355: * along with this program. Look for COPYING file in the top folder. jaroslav@355: * If not, see http://opensource.org/licenses/GPL-2.0. jaroslav@355: */ jaroslav@355: package org.apidesign.bck2brwsr.tck; jaroslav@355: jaroslav@355: import org.apidesign.bck2brwsr.vmtest.Compare; jaroslav@355: import org.apidesign.bck2brwsr.vmtest.VMTest; jaroslav@355: import org.testng.annotations.Factory; jaroslav@355: jaroslav@355: /** jaroslav@355: * jaroslav@355: * @author Jaroslav Tulach jaroslav@355: */ jaroslav@411: public class CloneTest { jaroslav@411: private int value; jaroslav@411: jaroslav@413: @Compare jaroslav@413: public Object notSupported() throws CloneNotSupportedException { jaroslav@413: return this.clone(); jaroslav@355: } jaroslav@355: jaroslav@411: @Compare public String sameClass() throws CloneNotSupportedException { jaroslav@411: return new Clnbl().clone().getClass().getName(); jaroslav@355: } jaroslav@411: jaroslav@411: @Compare public boolean differentInstance() throws CloneNotSupportedException { jaroslav@411: Clnbl orig = new Clnbl(); jaroslav@411: return orig == orig.clone(); jaroslav@392: } jaroslav@411: jaroslav@411: @Compare public int sameReference() throws CloneNotSupportedException { jaroslav@412: CloneTest self = this; jaroslav@411: Clnbl orig = new Clnbl(); jaroslav@411: self.value = 33; jaroslav@411: orig.ref = self; jaroslav@411: return ((Clnbl)orig.clone()).ref.value; jaroslav@394: } jaroslav@411: jaroslav@411: @Compare public int sameValue() throws CloneNotSupportedException { jaroslav@411: Clnbl orig = new Clnbl(); jaroslav@411: orig.value = 10; jaroslav@411: return ((Clnbl)orig.clone()).value; jaroslav@392: } jaroslav@355: jaroslav@355: @Factory jaroslav@355: public static Object[] create() { jaroslav@411: return VMTest.create(CloneTest.class); jaroslav@355: } jaroslav@355: jaroslav@411: public static final class Clnbl implements Cloneable { jaroslav@411: public CloneTest ref; jaroslav@411: private int value; jaroslav@411: jaroslav@411: @Override jaroslav@411: public Object clone() throws CloneNotSupportedException { jaroslav@411: return super.clone(); jaroslav@411: } jaroslav@411: } jaroslav@355: }