Skip to content

Commit dfbfa69

Browse files
committed
patches
1 parent 79f5174 commit dfbfa69

3 files changed

Lines changed: 12 additions & 35 deletions

File tree

‎v4-cokapi/backends/ruby/pg_logger.rb‎

Lines changed: 12 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Ruby backend for Online "Python" Tutor
22
# created on 2015-06-29 by Philip Guo
3+
# first deployed on 2015-07-15
34
#
45
# WARNING: this script only works on a *hacked version* of Ruby 2.X since
56
# we use the TracePoint API and custom fields such as binding::frame_id.
@@ -10,40 +11,25 @@
1011

1112
# TODO
1213
#
13-
# fix these tests:
14-
#
15-
# in frontend, maybe '=' isn't a valid CSS selector. also escape '?' too
16-
# tests/blocks-iterate.rb
17-
#
18-
# - test syntax errors in the OPT frontend
1914
# - display the 'binding' within a proc/lambda object, which represents
2015
# https://codequizzes.wordpress.com/2014/04/07/rubys-self-keyword-and-implicit-self/
2116
# its closure. test on tests/proc-return.rb
22-
# - support gets() for user input using the restart hack mechanism
23-
# - user input stored in $_
24-
# - support 'include'-ing a module and bringing in variables into namespace
25-
# - maybe this already works?
26-
# - cosmetic issues in the OPT frontend for Ruby:
27-
# - relabel "Global frame" as "Globals" or something
28-
# - display None values as 'nil'
29-
# - display booleans as 'true' and 'false'
30-
# - rename 'list' to 'array' - check
31-
# - rename 'dict' to 'hash' - check
32-
# - rename 'instance' to 'object' - check
33-
# - rename 'function' to 'method' - check
34-
# - display private and protected attributes
17+
#
18+
# - support gets() for taking user input using the restart hack mechanism
19+
# that we used for Python. user input stored in $_
20+
#
21+
# - properly display private and protected attributes
3522
#
3623
# Limitations/quirks:
37-
# - no support for (lexical) environment pointers, since MRI doesn't seem to
38-
# expose them. We can see only the current (dynamic) stack backtrace
39-
# with debug_inspector.
24+
# - no support yet for (lexical) environment pointers, since MRI doesn't
25+
# seem to expose them. We can see only the current (dynamic) stack
26+
# backtrace with debug_inspector.
4027
# - NB: is this true? at least we have 'binding' for procs/lambdas
4128
#
42-
# - keeps executing for a few more lines after an exception -- dunno if
29+
# - it keeps executing for a few more lines after an exception -- dunno if
4330
# that's standard Ruby behavior or not
4431
#
45-
# - method aliases show up as separate Method objects instead of the
46-
# same one
32+
# - method aliases show up as separate Method objects instead of the same one
4733
#
4834
# - if you write, say, "require 'date'", it will pull in classes from
4935
# the date module into globals, which might make the display HUGE
@@ -366,7 +352,6 @@ def encode(dat)
366352
toplevel_constants = (Module.constants - base_constants_set) # set difference
367353
entry['ordered_globals'].concat(toplevel_constants.map { |e| e.to_s })
368354
toplevel_constants.each do |varname|
369-
#val = eval(varname.to_s) # TODO: is there a better way? this seems hacky! # yes, see below
370355
val = Module.const_get(varname)
371356
globals[varname.to_s] = pg_encoder.encode(val)
372357
end
@@ -527,7 +512,7 @@ def self.iseq_local_variables iseq
527512
n_lines_added = 1
528513
else
529514
cod << "\nnil"
530-
n_lines_added = 2
515+
n_lines_added = 1 # pretty sure this is 1 and not 2
531516
end
532517

533518
eval(cod) # the filename of the user's code is '(eval)'

‎v4-cokapi/backends/ruby/tests/syntax-error-2.golden‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
SyntaxError -- blarrrggg!!!
2-
(eval):10: syntax error, unexpected end-of-input, expecting keyword_end
3-
10
4-
syntax error, unexpected end-of-input, expecting keyword_end
51
{
62
"code": "def say_hi\n if @names.nil?\n puts \"...\"\n else if @names.respond_to?(\"each\") # 'else if' is wrong\n @names.each do |name|\n puts \"Hello #{name}!\"\n end\n end\nend\n",
73
"trace": [

‎v4-cokapi/backends/ruby/tests/syntax-error.golden‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
SyntaxError -- blarrrggg!!!
2-
(eval):3: syntax error, unexpected tIDENTIFIER, expecting end-of-input
3-
3
4-
syntax error, unexpected tIDENTIFIER, expecting end-of-input
51
{
62
"code": "x = 1\ny = 2\nz = 3x\nq = x + y\n",
73
"trace": [

0 commit comments

Comments
 (0)