提交 dc175212 编写于 作者: K kohsuke

changing my mind about the operator syntax. I think || and && are better than | and &.

git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@33708 71c3de6d-444a-0410-be80-ed276b4c234a
上级 eb51d46d
......@@ -82,8 +82,8 @@ options { generateAmbigWarnings=false; }
class LabelExpressionLexer extends Lexer;
AND: "&";
OR: "|";
AND: "&&";
OR: "||";
NOT: "!";
IMPLIES:"->";
IFF: "<->";
......
......@@ -31,7 +31,7 @@ import hudson.util.VariableResolver;
* Atomic single token label, like "foo" or "bar".
*
* @author Kohsuke Kawaguchi
* @since 1.COMPOSITELABEL
* @since 1.372
*/
public class LabelAtom extends Label {
public LabelAtom(String name) {
......
......@@ -30,7 +30,7 @@ import hudson.util.VariableResolver;
* Boolean expression of labels.
*
* @author Kohsuke Kawaguchi
* @since 1.COMPOSITELABEL
* @since 1.372
*/
public abstract class LabelExpression extends Label {
protected LabelExpression(String name) {
......
......@@ -27,10 +27,10 @@ package hudson.model.label;
* Precedence of the top most operator.
*
* @author Kohsuke Kawaguchi
* @since 1.COMPOSITELABEL
* @since 1.372
*/
public enum LabelOperatorPrecedence {
ATOM(null), NOT("!"), AND("&"), OR("|"), IMPLIES("->"), IFF("<->");
ATOM(null), NOT("!"), AND("&&"), OR("||"), IMPLIES("->"), IFF("<->");
/**
* String representation of this operator.
......
......@@ -18,12 +18,12 @@
<dt>!expr</dt>
<dd>negation</dd>
<dt>expr&amp;expr</dt>
<dt>expr&amp;&amp;expr</dt>
<dd>
and
</dd>
<dt>expr|expr</dt>
<dt>expr||expr</dt>
<dd>
or
</dd>
......@@ -37,7 +37,7 @@
<dt>a &lt;-> b</dt>
<dd>
"if and only if" operator. Equivalent to <tt>a&amp;b |!a&amp;!b</tt>.
"if and only if" operator. Equivalent to <tt>a&amp;&amp;b || !a&amp;&amp;!b</tt>.
For example, <tt>windows->sfbay</tt> could be thought of as "if run on a Windows slave,
that slave must be in the SF bay area, but if not on Windows, it must not be in the bay area."
</dd>
......
......@@ -60,10 +60,10 @@ public class LabelExpressionTest extends HudsonTestCase {
return true;
}
});
p1.setAssignedLabel(hudson.getLabel("win & 32bit"));
p1.setAssignedLabel(hudson.getLabel("win && 32bit"));
FreeStyleProject p2 = createFreeStyleProject();
p2.setAssignedLabel(hudson.getLabel("win & 32bit"));
p2.setAssignedLabel(hudson.getLabel("win && 32bit"));
FreeStyleProject p3 = createFreeStyleProject();
p3.setAssignedLabel(hudson.getLabel("win"));
......@@ -118,13 +118,13 @@ public class LabelExpressionTest extends HudsonTestCase {
public void testParser() throws Exception {
parseAndVerify("foo", "foo");
parseAndVerify("32bit.dot", "32bit.dot");
parseAndVerify("foo|bar", "foo | bar");
parseAndVerify("foo||bar", "foo || bar");
// user-given parenthesis is preserved
parseAndVerify("foo|bar&zot", "foo|bar&zot");
parseAndVerify("foo|(bar&zot)", "foo|(bar&zot)");
parseAndVerify("foo||bar&&zot", "foo||bar&&zot");
parseAndVerify("foo||(bar&&zot)", "foo||(bar&&zot)");
parseAndVerify("(foo|bar)&zot", "(foo|bar)&zot");
parseAndVerify("(foo||bar)&&zot", "(foo||bar)&&zot");
parseAndVerify("foo->bar", "foo ->\tbar");
parseAndVerify("!foo<->bar", "!foo <-> bar");
}
......@@ -144,8 +144,8 @@ public class LabelExpressionTest extends HudsonTestCase {
public void testComposite() {
LabelAtom x = hudson.getLabelAtom("x");
assertEquals("!!x",x.not().not().getName());
assertEquals("(x|x)&x",x.or(x).and(x).getName());
assertEquals("x&x|x",x.and(x).or(x).getName());
assertEquals("(x||x)&&x",x.or(x).and(x).getName());
assertEquals("x&&x||x",x.and(x).or(x).getName());
}
private void parseShouldFail(String expr) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册