metron-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cestella <...@git.apache.org>
Subject [GitHub] metron pull request #606: METRON-980: Short circuit operations for Stellar
Date Fri, 02 Jun 2017 11:51:42 GMT
Github user cestella commented on a diff in the pull request:

    https://github.com/apache/metron/pull/606#discussion_r119838484
  
    --- Diff: metron-platform/metron-common/src/test/java/org/apache/metron/common/stellar/StellarTest.java
---
    @@ -634,6 +679,40 @@ public void testLogicalFunctions() throws Exception {
         Assert.assertTrue(runPredicate("not(IN_SUBNET(ip_dst_addr, '192.168.0.0/24'))", v->
variableMap.get(v)));
       }
     
    +  @Test
    +  public void testShortCircuit_conditional() throws Exception {
    +    Assert.assertEquals("foo", run("if true then 'foo' else THROW('expression')", new
HashMap<>()));
    +    Assert.assertEquals("foo", run("true ? 'foo' : THROW('expression')", new HashMap<>()));
    +    Assert.assertEquals("foo", run("if false then THROW('exception') else 'foo'", new
HashMap<>()));
    +    Assert.assertEquals("foo", run("false ? THROW('exception') : 'foo'", new HashMap<>()));
    +    Assert.assertEquals(true, run("RET_TRUE(if true then 'foo' else THROW('expression'))",
new HashMap<>()));
    +    Assert.assertEquals("foo", run("if true or (true or THROW('if exception')) then 'foo'
else THROW('expression')", new HashMap<>()));
    +    Assert.assertEquals("foo", run("if true or (false or THROW('if exception')) then
'foo' else THROW('expression')", new HashMap<>()));
    +    Assert.assertEquals("foo", run("if NOT(true or (false or THROW('if exception')))
then THROW('expression') else 'foo'", new HashMap<>()));
    +    Assert.assertEquals("foo", run("if NOT('metron' in [ 'metron', 'metronicus'] ) then
THROW('expression') else 'foo'", new HashMap<>()));
    +  }
    +
    +  @Test
    +  public void testShortCircuit_boolean() throws Exception {
    +    Assert.assertTrue(runPredicate("'metron' in ['metron', 'metronicus', 'mortron'] or
(true or THROW('exception'))", x -> null));
    --- End diff --
    
    Isn't that too many closing parens after the throw?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message