Skip to content

Commit

Permalink
Remove groovy dependency, fix #351
Browse files Browse the repository at this point in the history
  • Loading branch information
gnodet committed Jan 30, 2019
1 parent cfa7d0c commit 2d4e5e1
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 35 deletions.
8 changes: 0 additions & 8 deletions style/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,6 @@
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<!-- keep in sync with groovy-eclipse-batch version -->
<version>2.4.4</version>
<scope>test</scope>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
*/
package org.jline.style;

import org.codehaus.groovy.runtime.DefaultGroovyMethods;
import org.jline.utils.AttributedString;
import org.junit.Test;

Expand Down Expand Up @@ -40,7 +39,7 @@ public void bundleProxyToString() {
public void bundleDefaultStyle() {
Styles styles = StyleBundleInvocationHandler.create(source, Styles.class);
AttributedString string = styles.boldRed("foo bar");
DefaultGroovyMethods.println(this, string.toAnsi());
System.out.println(string.toAnsi());
assert string.equals(new AttributedString("foo bar", BOLD.foreground(RED)));
}

Expand All @@ -61,15 +60,15 @@ public void bundleDefaultStyleMissingButSourceReferenced() {
source.set("test", "missingDefaultStyle", "bold");
Styles styles = StyleBundleInvocationHandler.create(source, Styles.class);
AttributedString string = styles.missingDefaultStyle("foo bar");
DefaultGroovyMethods.println(this, string.toAnsi());
System.out.println(string.toAnsi());
assert string.equals(new AttributedString("foo bar", BOLD));
}

@Test
public void bundleStyleNameWithDefaultStyle() {
Styles styles = StyleBundleInvocationHandler.create(source, Styles.class);
AttributedString string = styles.boldRedObjectWithStyleName("foo bar");
DefaultGroovyMethods.println(this, string.toAnsi());
System.out.println(string.toAnsi());
assert string.equals(new AttributedString("foo bar", BOLD.foreground(RED)));
}

Expand All @@ -78,7 +77,7 @@ public void bundleSourcedStyle() {
source.set("test", "boldRed", "bold,fg:yellow");
Styles styles = StyleBundleInvocationHandler.create(source, Styles.class);
AttributedString string = styles.boldRed("foo bar");
DefaultGroovyMethods.println(this, string.toAnsi());
System.out.println(string.toAnsi());
assert string.equals(new AttributedString("foo bar", BOLD.foreground(YELLOW)));
}

Expand All @@ -87,7 +86,7 @@ public void bundleExplicitStyleGroup() {
source.set("test2", "boldRed", "bold,fg:yellow");
Styles styles = StyleBundleInvocationHandler.create(new StyleResolver(source, "test2"), Styles.class);
AttributedString string = styles.boldRed("foo bar");
DefaultGroovyMethods.println(this, string.toAnsi());
System.out.println(string.toAnsi());
assert string.equals(new AttributedString("foo bar", BOLD.foreground(YELLOW)));
}

Expand Down
26 changes: 14 additions & 12 deletions style/src/test/java/org/jline/style/StyleExpressionTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@
*/
package org.jline.style;

import org.codehaus.groovy.runtime.DefaultGroovyMethods;
import org.jline.utils.AttributedString;
import org.jline.utils.AttributedStringBuilder;
import org.junit.Before;
import org.junit.Test;

import static org.jline.utils.AttributedStyle.*;
import static org.jline.utils.AttributedStyle.BOLD;
import static org.jline.utils.AttributedStyle.CYAN;
import static org.jline.utils.AttributedStyle.DEFAULT;
import static org.jline.utils.AttributedStyle.RED;

/**
* Tests for {@link StyleExpression}.
Expand All @@ -32,28 +34,28 @@ public void setUp() {
@Test
public void evaluateExpressionWithPrefixAndSuffix() {
AttributedString result = underTest.evaluate("foo @{bold bar} baz");
DefaultGroovyMethods.println(this, result.toAnsi());
System.out.println(result.toAnsi());
assert result.equals(new AttributedStringBuilder().append("foo ").append("bar", BOLD).append(" baz").toAttributedString());
}

@Test
public void evaluateExpressionWithPrefix() {
AttributedString result = underTest.evaluate("foo @{bold bar}");
DefaultGroovyMethods.println(this, result.toAnsi());
System.out.println(result.toAnsi());
assert result.equals(new AttributedStringBuilder().append("foo ").append("bar", BOLD).toAttributedString());
}

@Test
public void evaluateExpressionWithSuffix() {
AttributedString result = underTest.evaluate("@{bold foo} bar");
DefaultGroovyMethods.println(this, result.toAnsi());
System.out.println(result.toAnsi());
assert result.equals(new AttributedStringBuilder().append("foo", BOLD).append(" bar").toAttributedString());
}

@Test
public void evaluateExpression() {
AttributedString result = underTest.evaluate("@{bold foo}");
DefaultGroovyMethods.println(this, result.toAnsi());
System.out.println(result.toAnsi());
assert result.equals(new AttributedString("foo", BOLD));
}

Expand All @@ -62,42 +64,42 @@ public void evaluateExpressionWithDefault()

{
AttributedString result = underTest.evaluate("@{.foo:-bold foo}");
DefaultGroovyMethods.println(this, result.toAnsi());
System.out.println(result.toAnsi());
assert result.equals(new AttributedString("foo", BOLD));
}

@Test
public void evaluateExpressionWithMultipleReplacements() {
AttributedString result = underTest.evaluate("@{bold foo} @{fg:red bar} @{underline baz}");
DefaultGroovyMethods.println(this, result.toAnsi());
System.out.println(result.toAnsi());
assert result.equals(new AttributedStringBuilder().append("foo", BOLD).append(" ").append("bar", DEFAULT.foreground(RED)).append(" ").append("baz", DEFAULT.underline()).toAttributedString());
}

@Test
public void evaluateExpressionWithRecursiveReplacements() {
AttributedString result = underTest.evaluate("@{underline foo @{fg:cyan bar}}");
DefaultGroovyMethods.println(this, result.toAnsi());
System.out.println(result.toAnsi());
assert result.equals(new AttributedStringBuilder().append("foo ", DEFAULT.underline()).append("bar", DEFAULT.underline().foreground(CYAN)).toAttributedString());
}

@Test
public void evaluateExpressionMissingVvalue() {
AttributedString result = underTest.evaluate("@{bold}");
DefaultGroovyMethods.println(this, result.toAnsi());
System.out.println(result.toAnsi());
assert result.equals(new AttributedString("@{bold}", DEFAULT));
}

@Test
public void evaluateExpressionMissingTokens() {
AttributedString result = underTest.evaluate("foo");
DefaultGroovyMethods.println(this, result.toAnsi());
System.out.println(result.toAnsi());
assert result.equals(new AttributedString("foo", DEFAULT));
}

@Test
public void evaluateExpressionWithPlaceholderValue() {
AttributedString result = underTest.evaluate("@{bold,fg:cyan ${foo\\}}");
DefaultGroovyMethods.println(this, result.toAnsi());
System.out.println(result.toAnsi());
assert result.equals(new AttributedString("${foo}", DEFAULT.bold().foreground(CYAN)));
}

Expand Down
19 changes: 10 additions & 9 deletions style/src/test/java/org/jline/style/StyleFactoryTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@
*/
package org.jline.style;

import org.codehaus.groovy.runtime.DefaultGroovyMethods;
import org.jline.utils.AttributedString;
import org.junit.Before;
import org.junit.Test;

import static org.jline.utils.AttributedStyle.*;
import static org.jline.utils.AttributedStyle.BOLD;
import static org.jline.utils.AttributedStyle.RED;
import static org.jline.utils.AttributedStyle.YELLOW;

/**
* Tests for {@link StyleFactory}.
Expand All @@ -31,51 +32,51 @@ public void setUp() {
@Test
public void styleDirect() {
AttributedString string = underTest.style("bold,fg:red", "foo bar");
DefaultGroovyMethods.println(this, string.toAnsi());
System.out.println(string.toAnsi());
assert string.equals(new AttributedString("foo bar", BOLD.foreground(RED)));
}

@Test
public void styleReferenced() {
source.set("test", "very-red", "bold,fg:red");
AttributedString string = underTest.style(".very-red", "foo bar");
DefaultGroovyMethods.println(this, string.toAnsi());
System.out.println(string.toAnsi());
assert string.equals(new AttributedString("foo bar", BOLD.foreground(RED)));
}

@Test
public void missingReferencedStyleWithDefault() {
AttributedString string = underTest.style(".very-red:-bold,fg:red", "foo bar");
DefaultGroovyMethods.println(this, string.toAnsi());
System.out.println(string.toAnsi());
assert string.equals(new AttributedString("foo bar", BOLD.foreground(RED)));
}

@Test
public void missingReferencedStyleWithCustomized() {
source.set("test", "very-red", "bold,fg:yellow");
AttributedString string = underTest.style(".very-red:-bold,fg:red", "foo bar");
DefaultGroovyMethods.println(this, string.toAnsi());
System.out.println(string.toAnsi());
assert string.equals(new AttributedString("foo bar", BOLD.foreground(YELLOW)));
}

@Test
public void styleFormat() {
AttributedString string = underTest.style("bold", "%s", "foo");
DefaultGroovyMethods.println(this, string.toAnsi());
System.out.println(string.toAnsi());
assert string.equals(new AttributedString("foo", BOLD));
}

@Test
public void evaluateExpression() {
AttributedString string = underTest.evaluate("@{bold foo}");
DefaultGroovyMethods.println(this, string.toAnsi());
System.out.println(string.toAnsi());
assert string.equals(new AttributedString("foo", BOLD));
}

@Test
public void evaluateExpressionWithFormat() {
AttributedString string = underTest.evaluate("@{bold %s}", "foo");
DefaultGroovyMethods.println(this, string.toAnsi());
System.out.println(string.toAnsi());
assert string.equals(new AttributedString("foo", BOLD));
}

Expand Down

0 comments on commit 2d4e5e1

Please sign in to comment.