github.com/qri-io/qri@v0.10.1-0.20220104210721-c771715036cb/transform/staticlark/testdata/some_funcs.star (about)

     1  
     2  def use_branch(container):
     3    a = 1
     4    b = 2
     5    if a < b:
     6      c = b + 1
     7    else:
     8      c = a + 1
     9    print('%d' % c)
    10  
    11  
    12  def branch_multiple(container):
    13    a = 1
    14    b = 2
    15    if a < b:
    16      c = b + 1
    17      d = a
    18      e = a + b
    19    else:
    20      c = a + 1
    21      print(c)
    22      e = c + 2
    23    print('%d' % e)
    24  
    25  
    26  def branch_no_else(container):
    27    a = 1
    28    b = 2
    29    if a < b:
    30      c = b + 1
    31      print('%d' % c)
    32    print('%d' % b)
    33  
    34  
    35  def branch_nested(container):
    36    a = 1
    37    b = 2
    38    if a < b:
    39      c = b + 1
    40      d = a
    41      if d > c:
    42        c = d + 2
    43    else:
    44      c = a + 1
    45      print(c)
    46      e = c + 2
    47    print('%d' % e)
    48  
    49  
    50  def top_level_func():
    51    items = []
    52    use_branch(items)
    53    if len(items) > 0:
    54      branch_multiple(items)
    55    else:
    56      branch_no_else(items)
    57    another_function()
    58  
    59  
    60  def another_function():
    61    more = []
    62    branch_nested(more)
    63    branch_no_else(more)
    64  
    65  
    66  def branch_elses(container):
    67    a = 1
    68    b = 2
    69    if a < b:
    70      c = b + 1
    71      if c < 1:
    72        print('small')
    73      elif c < 5:
    74        print('medium')
    75      else:
    76        print('large')
    77    else:
    78      print('ok')
    79    print('done')
    80  
    81  def branch_elses_contained(container):
    82    a = 1
    83    b = 2
    84    if a < b:
    85      c = b + 1
    86      if c < 1:
    87        print('small')
    88      elif c < 5:
    89        print('medium')
    90      else:
    91        print('large')
    92      print('sized')
    93    else:
    94      print('ok')
    95    print('done')