-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add `debug.caller()` * fix non-precompiled
- Loading branch information
1 parent
0768dac
commit 6152b0b
Showing
2 changed files
with
49 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,29 @@ | ||
import debug | ||
|
||
class A end | ||
debug.attrdump(A) #- should not crash -# | ||
debug.attrdump(A) #- should not crash -# | ||
|
||
# debug.caller() | ||
def caller_name_chain() | ||
import debug | ||
import introspect | ||
var i = 1 | ||
var ret = [] | ||
var caller = debug.caller(i) | ||
while caller | ||
ret.push(introspect.name(caller)) | ||
i += 1 | ||
caller = debug.caller(i) | ||
end | ||
return ret | ||
end | ||
var chain = caller_name_chain() | ||
assert(chain[0] == 'caller_name_chain') | ||
|
||
def guess_my_name__() | ||
return caller_name_chain() | ||
end | ||
chain = guess_my_name__() | ||
print(chain) | ||
assert(chain[0] == 'caller_name_chain') | ||
assert(chain[1] == 'guess_my_name__') |