You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Eric Milles (Jira)" <ji...@apache.org> on 2023/01/20 14:57:00 UTC

[jira] [Updated] (GROOVY-10909) bytecode for in, !in, !() and ?:

     [ https://issues.apache.org/jira/browse/GROOVY-10909?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Eric Milles updated GROOVY-10909:
---------------------------------
    Description: 
Consider the following:
{code:groovy}
List getList() { ['xx'] }
@groovy.transform.CompileStatic
void test(object) {
  def others = [], strings = []
  if (object in list) { // 4 of 8 branches missed
    strings << object
  }
  if (!(object in list)) { // 4 of 10 branched missed
    others << object
  }
  println others
  println strings
}
test(null)
test('xx')
test([''])
{code}

When unit testing, I noticed 4 of 10 branches missed for "if (!(item in list)) ...".  When compiled and executed dynamically, it shows 2 of 2 branches covered (safe call to "list.isCase(value)").

  was:
Consider the following:
{code:groovy}
List getList() { ['xx'] }
@groovy.transform.CompileStatic
void test(object) {
  def others = [], strings = []
  if (object in list) { // 4 of 8 branches missed
    strings << object
  }
  if (!(object in list)) { // 4 of 10 branched missed
    others << object
  }
  println others
  println strings
}
test(null)
test('xx')
test([''])
{code}

When unit testing, I noticed 4 of 10 branches missed for "if (!(value in list)) ...".  When compiled and executed dynamically, it shows 2 of 2 branches covered (safe call to "list.isCase(value)").


> bytecode for in, !in, !() and ?:
> --------------------------------
>
>                 Key: GROOVY-10909
>                 URL: https://issues.apache.org/jira/browse/GROOVY-10909
>             Project: Groovy
>          Issue Type: Bug
>          Components: bytecode, Compiler, Static compilation
>            Reporter: Eric Milles
>            Assignee: Eric Milles
>            Priority: Minor
>
> Consider the following:
> {code:groovy}
> List getList() { ['xx'] }
> @groovy.transform.CompileStatic
> void test(object) {
>   def others = [], strings = []
>   if (object in list) { // 4 of 8 branches missed
>     strings << object
>   }
>   if (!(object in list)) { // 4 of 10 branched missed
>     others << object
>   }
>   println others
>   println strings
> }
> test(null)
> test('xx')
> test([''])
> {code}
> When unit testing, I noticed 4 of 10 branches missed for "if (!(item in list)) ...".  When compiled and executed dynamically, it shows 2 of 2 branches covered (safe call to "list.isCase(value)").



--
This message was sent by Atlassian Jira
(v8.20.10#820010)