summaryrefslogtreecommitdiffhomepage
path: root/tests/custom/03_stdlib/39_trace
blob: 2b2295ade2c86c0f11a1ce4bd600c84797317e29 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
The `trace()` function sets the execution trace level of the VM.

Throws an exception if trace level argument is not a valid integer.

Returns the previously used execution trace level.

-- Testcase --
{%
	printf("Code before enabling tracing.\n");

	trace(1);

	printf("Code after enabling tracing.\n");

	trace(0);

	printf("Code after disabling tracing.\n");
%}
-- End --

-- Expect stdout --
Code before enabling tracing.
Code after enabling tracing.
Code after disabling tracing.
-- End --

-- Expect stderr --
  [-2] 1
  [-1] "function trace(...) { [native code] }"
  [+1] 0
        [stdin]:4      trace(1);
0000001c  POP
  [-1] 0
0000001d  LVAR {0x0}	; "printf"
  [+1] "function printf(...) { [native code] }"
        [stdin]:6      printf("Code after enabling tracing.\n");
00000022  LOAD {0x3}	; "Code after enabling tracing.\n"
  [+2] "Code after enabling tracing.\n"
        [stdin]:6      printf("Code after enabling tracing.\n");
00000027  CALL {0x1}
  [*] CALLFRAME[1]
   |- stackframe 1/3
   |- ctx null
  [-2] "Code after enabling tracing.\n"
  [-1] "function printf(...) { [native code] }"
  [+1] 29
        [stdin]:6      printf("Code after enabling tracing.\n");
0000002c  POP
  [-1] 29
0000002d  LVAR {0x2}	; "trace"
  [+1] "function trace(...) { [native code] }"
        [stdin]:8      trace(0);
00000032  LOAD8 {0}
  [+2] 0
        [stdin]:8      trace(0);
00000034  CALL {0x1}
  [*] CALLFRAME[1]
   |- stackframe 1/3
   |- ctx null
-- End --


Passing an invalid trace value throws an exception.

-- Testcase --
{%
	trace("inval");
%}
-- End --

-- Expect stderr --
Type error: Invalid level specified
In line 2, byte 15:

 `    trace("inval");`
  Near here -------^


-- End --