"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/test/org/codehaus/groovy/ast/tools/WideningCategoriesTest.groovy" between
apache-groovy-src-3.0.8.zip and apache-groovy-src-3.0.9.zip

About: Groovy is an agile dynamic (scripting) language for the Java Platform. It has features similar to those of Python, Ruby, Perl, and Smalltalk. Source release.

WideningCategoriesTest.groovy  (apache-groovy-src-3.0.8):WideningCategoriesTest.groovy  (apache-groovy-src-3.0.9)
skipping to change at line 23 skipping to change at line 23
* software distributed under the License is distributed on an * software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the * KIND, either express or implied. See the License for the
* specific language governing permissions and limitations * specific language governing permissions and limitations
* under the License. * under the License.
*/ */
package org.codehaus.groovy.ast.tools package org.codehaus.groovy.ast.tools
import org.codehaus.groovy.ast.ClassNode import org.codehaus.groovy.ast.ClassNode
import org.codehaus.groovy.ast.GenericsTestCase import org.codehaus.groovy.ast.GenericsTestCase
import static org.codehaus.groovy.ast.tools.WideningCategories.*
import static org.codehaus.groovy.ast.ClassHelper.* import static org.codehaus.groovy.ast.ClassHelper.*
import org.codehaus.groovy.ast.tools.WideningCategories.LowestUpperBoundClassNod e import static org.codehaus.groovy.ast.tools.WideningCategories.*
class WideningCategoriesTest extends GenericsTestCase { final class WideningCategoriesTest extends GenericsTestCase {
void testBuildCommonTypeWithNullClassNode() { void testBuildCommonTypeWithNullClassNode() {
ClassNode a = null ClassNode a = null
ClassNode b = make(Serializable) ClassNode b = make(Serializable)
assert lowestUpperBound(a,b) == null assert lowestUpperBound(a,b) == null
assert lowestUpperBound(b,a) == null assert lowestUpperBound(b,a) == null
} }
void testBuildCommonTypeWithObjectClassNode() { void testBuildCommonTypeWithObjectClassNode() {
ClassNode a = OBJECT_TYPE ClassNode a = OBJECT_TYPE
skipping to change at line 178 skipping to change at line 178
ClassNode type = lowestUpperBound(a, b) ClassNode type = lowestUpperBound(a, b)
assert type.name =~ /.*Top/ assert type.name =~ /.*Top/
assert type.superClass == make(Top) // includes interface GroovyObject assert type.superClass == make(Top) // includes interface GroovyObject
assert type.interfaces as Set == [make(Serializable)] as Set // extra in terface assert type.interfaces as Set == [make(Serializable)] as Set // extra in terface
type = lowestUpperBound(b, a) type = lowestUpperBound(b, a)
assert type.name =~ /.*Top/ assert type.name =~ /.*Top/
assert type.superClass == make(Top) assert type.superClass == make(Top)
assert type.interfaces as Set == [make(Serializable)] as Set assert type.interfaces as Set == [make(Serializable)] as Set
} }
// GROOVY-8111
void testBuildCommonTypeFromTwoClassesWithTwoCommonInterfacesOneIsSelfRefere
ntial() {
ClassNode a = boolean_TYPE
ClassNode b = extractTypesFromCode("${getClass().getName()}.Pair<String,
String> type").type
ClassNode lub = lowestUpperBound(a, b)
assert lub.superClass == OBJECT_TYPE
assert lub.interfaces as Set == [make(Comparable), make(Serializable)] a
s Set
lub = lowestUpperBound(b, a)
assert lub.superClass == OBJECT_TYPE
assert lub.interfaces as Set == [make(Comparable), make(Serializable)] a
s Set
}
void testStringWithGString() { void testStringWithGString() {
ClassNode a = make(String) ClassNode a = make(String)
ClassNode b = make(GString) ClassNode b = make(GString)
ClassNode type = lowestUpperBound(a,b) ClassNode type = lowestUpperBound(a,b)
assert type.interfaces as Set == [make(CharSequence), make(Comparable), make(Serializable)] as Set assert type.interfaces as Set == [make(CharSequence), make(Comparable), make(Serializable)] as Set
} }
void testDistinctPrimitiveTypes() { void testDistinctPrimitiveTypes() {
ClassNode a = int_TYPE // primitive int ClassNode a = int_TYPE // primitive int
ClassNode b = long_TYPE // primitive long ClassNode b = long_TYPE // primitive long
skipping to change at line 340 skipping to change at line 354
void testLUBOfArrayTypes() { void testLUBOfArrayTypes() {
def typeA = extractTypesFromCode('Number[] type').type def typeA = extractTypesFromCode('Number[] type').type
def typeB = extractTypesFromCode('Integer[] type').type def typeB = extractTypesFromCode('Integer[] type').type
def superType = lowestUpperBound(typeA, typeB) def superType = lowestUpperBound(typeA, typeB)
assert superType.isArray() assert superType.isArray()
def component = superType.getComponentType() def component = superType.getComponentType()
assert component == make(Number) assert component == make(Number)
} }
// ---------- Classes and Interfaces used in this unit test ---------------- // ---------- Classes and Interfaces used in this unit test ----------------
private static interface InterfaceA {} private static interface InterfaceA {}
private static interface InterfaceB {} private static interface InterfaceB {}
private static interface InterfaceE {} private static interface InterfaceE {}
private static interface InterfaceCA extends InterfaceA {} private static interface InterfaceCA extends InterfaceA {}
private static interface InterfaceDA extends InterfaceA {} private static interface InterfaceDA extends InterfaceA {}
private static interface InterfaceCAB extends InterfaceA, InterfaceB {} private static interface InterfaceCAB extends InterfaceA, InterfaceB {}
private static interface InterfaceDAB extends InterfaceA, InterfaceB {} private static interface InterfaceDAB extends InterfaceA, InterfaceB {}
private static interface InterfaceDABE extends InterfaceA, InterfaceB, Inter faceE {} private static interface InterfaceDABE extends InterfaceA, InterfaceB, Inter faceE {}
private static class ClassA {} private static class ClassA {}
skipping to change at line 362 skipping to change at line 377
private static class ClassB1 extends ClassB {} private static class ClassB1 extends ClassB {}
private static class ClassA1_Serializable extends ClassA implements Serializ able {} private static class ClassA1_Serializable extends ClassA implements Serializ able {}
private static class ClassB1_Serializable extends ClassB implements Serializ able {} private static class ClassB1_Serializable extends ClassB implements Serializ able {}
private static class Top {} private static class Top {}
private static class BottomA extends Top implements Serializable {} private static class BottomA extends Top implements Serializable {}
private static class BottomB extends Top implements Serializable {} private static class BottomB extends Top implements Serializable {}
private static class PTop<E> {} private static class PTop<E> {}
private static class PTopInt extends PTop<Integer> implements Serializable { } private static class PTopInt extends PTop<Integer> implements Serializable { }
private static class PTopLong extends PTop<Long> implements Serializable {} private static class PTopLong extends PTop<Long > implements Serializable {
}
private static class Pair<L,R> implements Map.Entry<L,R>, Comparable<Pair<L,
R>>, Serializable {
public final L left
public final R right
private Pair(final L left, final R right) {
this.left = left
this.right = right
}
static <L, R> Pair<L, R> of(final L left, final R right) {
return new Pair<>(left, right)
}
L getKey() { left }
R getValue() { right }
R setValue(R value) { right }
int compareTo(Pair<L,R> that) { 0 }
}
} }
 End of changes. 6 change blocks. 
4 lines changed or deleted 41 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)