github.com/coyove/nj@v0.0.0-20221110084952-c7f8db1065c3/tests/goto.nj.lua (about)

     1  local i = 0
     2  print("test goto")
     3  
     4  goto a1
     5  :: a2
     6  ::
     7  i=i+1
     8  goto a3
     9  
    10  ::a1::
    11  assert(true)
    12  i=i+1
    13  goto a2
    14  
    15  :: a3::
    16  assert(i == 2)
    17  
    18  if false then
    19  ::iflabel::
    20      i = 10
    21  end
    22  
    23  if i== 10 then goto iflabel2 end
    24  
    25  goto iflabel ::iflabel2::
    26  
    27  assert(i == 10)
    28  
    29  function a()
    30  ::innerlabel::
    31  assert(false)
    32  end
    33  
    34  -- goto innerlabel panic
    35  
    36  _GOTO = "goto"