Repository: incubator-groovy
Updated Branches:
  refs/heads/GROOVY_2_4_X 409b4afd1 -> 070a43df7


GROOVY-7538: Add tests (closes #79)


Project: http://git-wip-us.apache.org/repos/asf/incubator-groovy/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-groovy/commit/070a43df
Tree: http://git-wip-us.apache.org/repos/asf/incubator-groovy/tree/070a43df
Diff: http://git-wip-us.apache.org/repos/asf/incubator-groovy/diff/070a43df

Branch: refs/heads/GROOVY_2_4_X
Commit: 070a43df78e4350001b8a5339f14fc6a3674404c
Parents: 409b4af
Author: Frank Pavageau <fpavag...@ekino.com>
Authored: Sat Aug 1 23:40:57 2015 +0200
Committer: pascalschumacher <pascalschumac...@gmx.net>
Committed: Tue Sep 1 06:59:55 2015 +0200

----------------------------------------------------------------------
 .../classgen/asm/sc/bugs/Groovy7538Bug.groovy   | 46 ++++++++++
 .../asm/sc/bugs/support/Groovy7538Support.java  | 96 ++++++++++++++++++++
 2 files changed, 142 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-groovy/blob/070a43df/src/test/org/codehaus/groovy/classgen/asm/sc/bugs/Groovy7538Bug.groovy
----------------------------------------------------------------------
diff --git 
a/src/test/org/codehaus/groovy/classgen/asm/sc/bugs/Groovy7538Bug.groovy 
b/src/test/org/codehaus/groovy/classgen/asm/sc/bugs/Groovy7538Bug.groovy
new file mode 100644
index 0000000..22feb69
--- /dev/null
+++ b/src/test/org/codehaus/groovy/classgen/asm/sc/bugs/Groovy7538Bug.groovy
@@ -0,0 +1,46 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+package org.codehaus.groovy.classgen.asm.sc.bugs
+
+import groovy.transform.NotYetImplemented
+import groovy.transform.stc.StaticTypeCheckingTestCase
+import org.codehaus.groovy.classgen.asm.sc.StaticCompilationTestSupport
+
+class Groovy7538Bug extends StaticTypeCheckingTestCase implements 
StaticCompilationTestSupport {
+    @NotYetImplemented
+    void testFluentSubTypeToSuperType() {
+        assertScript '''import 
org.codehaus.groovy.classgen.asm.sc.bugs.support.Groovy7538Support
+            
Groovy7538Support.assertThat("true").isNotEmpty().isNotEqualTo("false")
+        '''
+    }
+
+    @NotYetImplemented
+    void testFluentSuperTypeToSubType() {
+        assertScript '''import 
org.codehaus.groovy.classgen.asm.sc.bugs.support.Groovy7538Support
+            
Groovy7538Support.assertThat("true").isNotEqualTo("false").isNotEmpty()
+        '''
+    }
+
+    void testIndependentAssertions() {
+        assertScript '''import 
org.codehaus.groovy.classgen.asm.sc.bugs.support.Groovy7538Support
+            Groovy7538Support.assertThat("true").isNotEmpty()
+            Groovy7538Support.assertThat("true").isNotEqualTo("false")
+        '''
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-groovy/blob/070a43df/src/test/org/codehaus/groovy/classgen/asm/sc/bugs/support/Groovy7538Support.java
----------------------------------------------------------------------
diff --git 
a/src/test/org/codehaus/groovy/classgen/asm/sc/bugs/support/Groovy7538Support.java
 
b/src/test/org/codehaus/groovy/classgen/asm/sc/bugs/support/Groovy7538Support.java
new file mode 100644
index 0000000..0ee598c
--- /dev/null
+++ 
b/src/test/org/codehaus/groovy/classgen/asm/sc/bugs/support/Groovy7538Support.java
@@ -0,0 +1,96 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+package org.codehaus.groovy.classgen.asm.sc.bugs.support;
+
+/*
+ * Test classes extracted and adapted from the AssertJ project.
+ */
+public class Groovy7538Support {
+    public static AbstractCharSequenceAssert<?, String> assertThat(String 
actual) {
+        return new StringAssert(actual);
+    }
+
+    public static class StringAssert extends 
AbstractCharSequenceAssert<StringAssert, String> {
+        protected StringAssert(String actual) {
+            super(actual, StringAssert.class);
+        }
+    }
+
+    public static abstract class AbstractCharSequenceAssert<S extends 
AbstractCharSequenceAssert<S, A>, A extends CharSequence>
+            extends AbstractAssert<S, A> {
+        protected AbstractCharSequenceAssert(A actual, Class<?> selfType) {
+            super(actual, selfType);
+        }
+
+        public S isNotEmpty() {
+            assertNotEmpty(actual);
+            return myself;
+        }
+
+        public void assertNotEmpty(CharSequence actual) {
+            assertNotNull(actual);
+            if (hasContents(actual)) {
+                return;
+            }
+            throw new IllegalArgumentException("Expecting actual not to be 
empty");
+        }
+
+        private void assertNotNull(CharSequence actual) {
+            if (actual != null) {
+                return;
+            }
+            throw new IllegalArgumentException("Expecting actual not to be 
null");
+        }
+
+        private static boolean hasContents(CharSequence s) {
+            return s.length() > 0;
+        }
+    }
+
+    public static abstract class AbstractAssert<S extends AbstractAssert<S, 
A>, A> {
+        protected final A actual;
+        protected final S myself;
+
+        protected AbstractAssert(A actual, Class<?> selfType) {
+            myself = (S) selfType.cast(this);
+            this.actual = actual;
+        }
+
+        public S isNotEqualTo(Object other) {
+            assertNotEqual(actual, other);
+            return myself;
+        }
+
+        private void assertNotEqual(Object actual, Object other) {
+            if (!equal(actual, other)) {
+                return;
+            }
+            throw new IllegalArgumentException("Expecting actual not to be 
equal to other");
+        }
+
+        private static boolean equal(Object actual, Object other) {
+            return (actual == other) || (actual != null && 
actual.equals(other));
+        }
+    }
+
+    public void assertString() {
+        assertThat("true").isNotEmpty().isNotEqualTo("false");
+        assertThat("true").isNotEqualTo("false").isNotEmpty();
+    }
+}

Reply via email to