tests/testthat/_snaps/02_flow_data_if.md

flow_data works with simple if and empty body

Code
  out
Output
  $nodes
    id block_type          code_str label
  1  0     header            fun(x)      
  2  1         if   if (x)  \n           
  3  2   standard                        
  4 -1        end                        
  5  3     return

  $edges
    from to edge_label arrow
  1    0  1               ->
  2    1  2          y    ->
  3    2 -1               ->
  4    1 -1          n    ->
  5   -1  3               ->

flow_data works with simple if

Code
  out
Output
  $nodes
    id block_type          code_str label
  1  0     header            fun(x)      
  2  1         if   if (x)  \n           
  3  2   standard               foo      
  4 -1        end                        
  5  3     return

  $edges
    from to edge_label arrow
  1    0  1               ->
  2    1  2          y    ->
  3    2 -1               ->
  4    1 -1          n    ->
  5   -1  3               ->

flow_data works with simple if else

Code
  out
Output
  $nodes
    id block_type          code_str label
  1  0     header            fun(x)      
  2  1         if   if (x)  \n           
  3  2   standard               foo      
  4  3   standard               bar      
  5 -1        end                        
  6  4     return

  $edges
    from to edge_label arrow
  1    0  1               ->
  2    1  2          y    ->
  3    2 -1               ->
  4    1  3          n    ->
  5    3 -1               ->
  6   -1  4               ->

flow_data works returning on the yes branch

Code
  out
Output
  $nodes
    id block_type          code_str label
  1  0     header            fun(x)      
  2  1         if   if (x)  \n           
  3  2   standard       return(foo)      
  4 -2     return                        
  5  3   standard               bar      
  6 -1        end                        
  7  4     return

  $edges
    from to edge_label arrow
  1    0  1               ->
  2    1  2          y    ->
  3    2 -2               ->
  4    1  3          n    ->
  5    3 -1               ->
  6   -1  4               ->

flow_data works stopping on the no branch

Code
  out
Output
  $nodes
    id block_type          code_str label
  1  0     header            fun(x)      
  2  1         if   if (x)  \n           
  3  2   standard               foo      
  4  3   standard         stop(bar)      
  5 -3       stop                        
  6 -1        end                        
  7  4     return

  $edges
    from to edge_label arrow
  1    0  1               ->
  2    1  2          y    ->
  3    2 -1               ->
  4    1  3          n    ->
  5    3 -3               ->
  6   -1  4               ->

flow_data works stopping on the yes branch and returning on the right branch

Code
  out
Output
  $nodes
    id block_type          code_str label
  1  0     header            fun(x)      
  2  1         if   if (x)  \n           
  3  2   standard         stop(foo)      
  4 -2       stop                        
  5  3   standard       return(bar)      
  6 -3     return                        
  7  4     return

  $edges
    from to edge_label arrow
  1    0  1               ->
  2    1  2          y    ->
  3    2 -2               ->
  4    1  3          n    ->
  5    3 -3               ->

flow_data works with nested if calls

Code
  out
Output
  $nodes
    id block_type          code_str label
  1  0     header            fun(x)      
  2  1         if   if (x)  \n           
  3  2         if   if (y)  \n           
  4  3   standard               foo      
  5  4   standard               bar      
  6 -2        end                        
  7 -1        end                        
  8  5     return

  $edges
    from to edge_label arrow
  1    0  1               ->
  2    1  2          y    ->
  3    2  3          y    ->
  4    3 -2               ->
  5    2  4          n    ->
  6    4 -2               ->
  7   -2 -1               ->
  8    1 -1          n    ->
  9   -1  5               ->
Code
  out
Output
  $nodes
    id block_type          code_str label
  1  0     header         fun(x, y)      
  2  1         if   if (x)  \n           
  3  2         if   if (y)  \n           
  4  3   standard            stop()      
  5 -3       stop                        
  6  4   standard            stop()      
  7 -4       stop                        
  8 -1        end                        
  9  5     return

  $edges
    from to edge_label arrow
  1    0  1               ->
  2    1  2          y    ->
  3    2  3          y    ->
  4    3 -3               ->
  5    2  4          n    ->
  6    1 -1          n    ->
  7   -1  5               ->


Try the flow package in your browser

Any scripts or data that you put into this service are public.

flow documentation built on June 7, 2023, 5:17 p.m.