• source navigation  • diff markup  • identifier search  • freetext search  • 

Sources/ucode/tests/custom/02_runtime/06_recursion

  1 Testing recursive invocations.
  2 
  3 
  4 1. Testing recursive invocation.
  5 
  6 -- Expect stdout --
  7 1
  8 2
  9 4
 10 8
 11 16
 12 32
 13 64
 14 128
 15 256
 16 512
 17 1024
 18 2048
 19 4096
 20 8192
 21 16384
 22 -- End --
 23 
 24 -- Testcase --
 25 {%
 26         function test(x) {
 27                 print(x, "\n");
 28 
 29                 if (x < 10000)
 30                         test(x * 2);
 31         }
 32 
 33         test(1);
 34 %}
 35 -- End --
 36 
 37 
 38 2. Testing infinite recursion.
 39 
 40 -- Expect stderr --
 41 Runtime error: Too much recursion
 42 In test(), line 3, byte 8:
 43   called from anonymous function ([stdin]:6:7)
 44 
 45  `        test();`
 46   Near here ---^
 47 
 48 
 49 -- End --
 50 
 51 -- Testcase --
 52 {%
 53         function test() {
 54                 test();
 55         }
 56 
 57         test();
 58 %}
 59 -- End --

This page was automatically generated by LXR 0.3.1.  •  OpenWrt