seeing_is_believing 3.0.0.beta.4 → 3.0.0.beta.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +0 -8
- data/Rakefile +1 -1
- data/Readme.md +65 -25
- data/bin/seeing_is_believing +1 -0
- data/docs/sib-streaming.gif +0 -0
- data/features/deprecated-flags.feature +62 -2
- data/features/errors.feature +12 -7
- data/features/examples.feature +143 -4
- data/features/flags.feature +89 -29
- data/features/regression.feature +58 -14
- data/features/support/env.rb +4 -0
- data/features/xmpfilter-style.feature +181 -36
- data/lib/seeing_is_believing.rb +44 -33
- data/lib/seeing_is_believing/binary.rb +31 -88
- data/lib/seeing_is_believing/binary/align_chunk.rb +30 -11
- data/lib/seeing_is_believing/binary/annotate_end_of_file.rb +10 -16
- data/lib/seeing_is_believing/binary/annotate_every_line.rb +5 -25
- data/lib/seeing_is_believing/binary/annotate_marked_lines.rb +136 -0
- data/lib/seeing_is_believing/binary/comment_lines.rb +8 -10
- data/lib/seeing_is_believing/binary/commentable_lines.rb +20 -26
- data/lib/seeing_is_believing/binary/config.rb +392 -0
- data/lib/seeing_is_believing/binary/data_structures.rb +57 -0
- data/lib/seeing_is_believing/binary/engine.rb +104 -0
- data/lib/seeing_is_believing/binary/{comment_formatter.rb → format_comment.rb} +6 -6
- data/lib/seeing_is_believing/binary/remove_annotations.rb +29 -28
- data/lib/seeing_is_believing/binary/rewrite_comments.rb +42 -43
- data/lib/seeing_is_believing/code.rb +105 -49
- data/lib/seeing_is_believing/debugger.rb +6 -5
- data/lib/seeing_is_believing/error.rb +6 -17
- data/lib/seeing_is_believing/evaluate_by_moving_files.rb +78 -129
- data/lib/seeing_is_believing/event_stream/consumer.rb +114 -64
- data/lib/seeing_is_believing/event_stream/events.rb +169 -11
- data/lib/seeing_is_believing/event_stream/handlers/debug.rb +57 -0
- data/lib/seeing_is_believing/event_stream/handlers/record_exitstatus.rb +18 -0
- data/lib/seeing_is_believing/event_stream/handlers/stream_json_events.rb +45 -0
- data/lib/seeing_is_believing/event_stream/handlers/update_result.rb +39 -0
- data/lib/seeing_is_believing/event_stream/producer.rb +25 -24
- data/lib/seeing_is_believing/hash_struct.rb +206 -0
- data/lib/seeing_is_believing/result.rb +20 -3
- data/lib/seeing_is_believing/the_matrix.rb +20 -12
- data/lib/seeing_is_believing/version.rb +1 -1
- data/lib/seeing_is_believing/wrap_expressions.rb +55 -115
- data/lib/seeing_is_believing/wrap_expressions_with_inspect.rb +14 -0
- data/seeing_is_believing.gemspec +1 -1
- data/spec/binary/alignment_specs.rb +27 -0
- data/spec/binary/comment_lines_spec.rb +3 -2
- data/spec/binary/config_spec.rb +657 -0
- data/spec/binary/engine_spec.rb +97 -0
- data/spec/binary/{comment_formatter_spec.rb → format_comment_spec.rb} +2 -2
- data/spec/binary/marker_spec.rb +71 -0
- data/spec/binary/options_spec.rb +0 -0
- data/spec/binary/remove_annotations_spec.rb +31 -18
- data/spec/binary/rewrite_comments_spec.rb +26 -11
- data/spec/code_spec.rb +190 -6
- data/spec/debugger_spec.rb +4 -0
- data/spec/evaluate_by_moving_files_spec.rb +38 -20
- data/spec/event_stream_spec.rb +265 -116
- data/spec/hash_struct_spec.rb +514 -0
- data/spec/seeing_is_believing_spec.rb +108 -46
- data/spec/spec_helper.rb +9 -0
- data/spec/wrap_expressions_spec.rb +207 -172
- metadata +30 -18
- data/docs/for-presentations +0 -33
- data/lib/seeing_is_believing/binary/annotate_xmpfilter_style.rb +0 -128
- data/lib/seeing_is_believing/binary/interpret_flags.rb +0 -156
- data/lib/seeing_is_believing/binary/parse_args.rb +0 -263
- data/lib/seeing_is_believing/event_stream/update_result.rb +0 -24
- data/lib/seeing_is_believing/inspect_expressions.rb +0 -21
- data/lib/seeing_is_believing/parser_helpers.rb +0 -82
- data/spec/binary/interpret_flags_spec.rb +0 -332
- data/spec/binary/parse_args_spec.rb +0 -415
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 19acf5dae90b9e2cbad24fb2152392f3d22ab1f2
|
4
|
+
data.tar.gz: 8c9bc8df800a1289cd0997c392027351798cbee1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d2198f2a94a2c5a570c087d8753feec78e71b08ac1b300d8e68cb4439e73111df75e1e610899853ccf33f205fc23330c65de0c9d19fbb24b4eba844f7ba6ce29
|
7
|
+
data.tar.gz: 0e5842837786d01d8d141c679b877074d0c4297059d1e2d80a7fc9f5d48a9e595b5c1be1ee0f3975b6edb70ffc995f97ba1be2076ae4154352c24818896505ac
|
data/.travis.yml
CHANGED
data/Rakefile
CHANGED
data/Readme.md
CHANGED
@@ -4,36 +4,28 @@
|
|
4
4
|
Seeing Is Believing
|
5
5
|
===================
|
6
6
|
|
7
|
-
Evaluates
|
7
|
+
Evaluates Ruby code, recording the results of each line.
|
8
8
|
Integrates with any extensible editor (I've integrated it with many already, see [the list](https://github.com/JoshCheek/seeing_is_believing#editor-integration).
|
9
9
|
|
10
10
|

|
11
11
|
|
12
12
|
Watch a [longer video](http://vimeo.com/73866851).
|
13
13
|
|
14
|
-
Works in Ruby 1.9, 2.0, 2.1, rubinius (I **think**, need to make better tests), still trying to get it working with Jruby.
|
14
|
+
Works in Ruby 1.9, 2.0, 2.1, 2.2, rubinius (I **think**, need to make better tests), still trying to get it working with Jruby.
|
15
15
|
|
16
16
|
Use The Binary
|
17
17
|
==============
|
18
18
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
* Smart enough to show
|
23
|
-
* method arguments
|
24
|
-
* if statement clauses
|
25
|
-
* values in a hash
|
26
|
-
* methods that are chained together across lines
|
27
|
-
* multiline string/symbol/regex
|
28
|
-
|
29
|
-
```sh
|
30
|
-
$ cat simple_example.rb
|
19
|
+
`cat simple_example.rb`
|
20
|
+
|
21
|
+
```ruby
|
31
22
|
5.times do |i|
|
32
23
|
i * 2
|
33
24
|
end
|
25
|
+
```
|
34
26
|
|
35
|
-
|
36
|
-
|
27
|
+
`seeing_is_believing simple_example.rb`
|
28
|
+
```ruby
|
37
29
|
5.times do |i| # => 5
|
38
30
|
i * 2 # => 0, 2, 4, 6, 8
|
39
31
|
end # => 5
|
@@ -64,7 +56,7 @@ result.exception # => nil
|
|
64
56
|
Install
|
65
57
|
=======
|
66
58
|
|
67
|
-
Currently requires Ruby 1.9 or 2.
|
59
|
+
Currently requires Ruby 1.9 or 2.x
|
68
60
|
|
69
61
|
$ gem install seeing_is_believing
|
70
62
|
|
@@ -101,17 +93,65 @@ or current buffer contents with the output of running it through
|
|
101
93
|
Known Issues
|
102
94
|
============
|
103
95
|
|
104
|
-
* `
|
105
|
-
|
106
|
-
|
96
|
+
* `begin; else; break; end` this code (an else without a resecue) will emit a warning in Ruby, and is omitted from `Parser`'s AST.
|
97
|
+
As such, I doubt that anyone will ever write it. But if you were to write it, it would blow up, because SiB rewrites your code, wrapping every expression that could have a value.
|
98
|
+
This code will be wrapped. But using the value is syntactically invalid in Ruby, because it constitutes a "void value expression" (aka a nightmare for anyone working with code).
|
99
|
+
I can't easily check it to seee if it's void since it's not in the parsed AST. But it's so edge taht I don't think it's worth worrying about.
|
100
|
+
|
101
|
+
Version 2
|
102
|
+
=========
|
103
|
+
|
104
|
+
Feature complete, I'll fix bugs in it until version 3 is released, though
|
105
|
+
|
106
|
+
Version 3
|
107
|
+
=========
|
107
108
|
|
108
|
-
|
109
|
-
|
109
|
+
These need to be done before release:
|
110
|
+
|
111
|
+
* Add default to number of captures (1000), require user to explicitly set it to infinity
|
112
|
+
* Update changelog with all changes
|
113
|
+
* Push the event stream up to the top level so we can expose it via the interface.
|
114
|
+
* Get it working on JRuby and Rbx
|
115
|
+
* Order frog stickers
|
116
|
+
* Figure out how to handle markers
|
117
|
+
|
118
|
+
Version 4
|
119
|
+
=========
|
110
120
|
|
111
121
|
* How about if begin/rescue/end was able to record the result on the rescue section
|
112
|
-
* How about if you could configure which kinds of results
|
113
|
-
|
114
|
-
*
|
122
|
+
* How about if you could configure which kinds of results you were interested in
|
123
|
+
(e.g. turn on/off recording of method definitions, and other results)
|
124
|
+
* What about recording the result of a line inside of a string interpolation,
|
125
|
+
e.g. "a#{\n1\n}b" could record line 2 is 1 and line 3 is "a\n1\nb"
|
126
|
+
This would require smarter annotators.
|
127
|
+
* Allow debugger to take a filename (ie debug to a file insteaad of to stderr)
|
128
|
+
* `--cd dir` cd to that dir before executing the code
|
129
|
+
* `--cd -` cd to the dir of the file being executed before executing it
|
130
|
+
* `--only-show-lines` output only on specified lines (doesn't change stdout/stderr/exceptions)
|
131
|
+
* More alignment strategies e.g. `min=40` would align to 40, unless that was too short.
|
132
|
+
Could have fallback strategies, so e.g. `-s min=40,fallback=line`
|
133
|
+
* Package Ruby with the editor downloads so that they don't require you to know so fkn much to set it up.
|
134
|
+
* Allow user to set marker
|
135
|
+
|
136
|
+
Inspiration
|
137
|
+
===========
|
138
|
+
|
139
|
+
* [Xmpfilter](http://www.rubydoc.info/gems/rcodetools/0.8.5.0/Rcodetools/XMPFilter), which is a part of the [rcodetools gem](https://rubygems.org/gems/rcodetools).
|
140
|
+
* Bret Victor's completely inspiring talk [Inventing on Principle](https://www.youtube.com/watch?v=PUv66718DII).
|
141
|
+
* My 8th Light mentor, [Doug Bradbury](http://blog.8thlight.com/doug-bradbury/archive.html) who asked me to make it for his Kids Ruby sessions (I don't think we ever finished integrating it, though >.<)
|
142
|
+
|
143
|
+
Interestingly, [Swift playground](https://www.youtube.com/watch?v=oY6nQS3MiF8&t=25m51s)
|
144
|
+
are very similar (though better integrated since they cerce you into using xcode).
|
145
|
+
Released about a year and a half before them, but maybe I should take advantage of
|
146
|
+
their marketing anyway: Swift Playgrounds for Ruby!! :P
|
147
|
+
|
148
|
+
Shout outs
|
149
|
+
==========
|
150
|
+
|
151
|
+
* Whitequark for all the work on [Parser](http://github.com/whitequark/parser/), which dramatically dramatically improved SiB (I used to have my own horribly shitty line-based parser)
|
152
|
+
* [Travis CI](https://travis-ci.org/JoshCheek/seeing_is_believing)... I love you times a million! So many difficult bugs have been caught by this.
|
153
|
+
It's so easy to work with, astoundingly convenient, helps me guarantee that SiB works on everyone else's computers, too. And it's free since SiB is open source.
|
154
|
+
I literally have a Travis CI sticker on my laptop, I love you that much.
|
115
155
|
|
116
156
|
License
|
117
157
|
=======
|
data/bin/seeing_is_believing
CHANGED
Binary file
|
@@ -5,8 +5,68 @@ Feature: Flags that are deprecated
|
|
5
5
|
As such, these flags will continue to not blow up,
|
6
6
|
even though they won't work anymore
|
7
7
|
|
8
|
-
Scenario: --shebang
|
9
|
-
When I run "seeing_is_believing -e 123 --shebang
|
8
|
+
Scenario: --shebang with errors
|
9
|
+
When I run "seeing_is_believing -e 123 --shebang path/to/bin"
|
10
10
|
Then stderr is empty
|
11
11
|
And stdout is "123 # => 123"
|
12
12
|
And the exit status is 0
|
13
|
+
|
14
|
+
Scenario: --shebang with errors
|
15
|
+
When I run "seeing_is_believing not_a_file.rb --shebang path/to/bin"
|
16
|
+
Then stdout is empty
|
17
|
+
And stderr is:
|
18
|
+
"""
|
19
|
+
Error: not_a_file.rb does not exist!
|
20
|
+
Deprecated: `--shebang path/to/bin` SiB now uses the Ruby it was invoked with
|
21
|
+
"""
|
22
|
+
|
23
|
+
Scenario: --number-of-captures without errors
|
24
|
+
Given the file "number_of_captures.rb":
|
25
|
+
"""
|
26
|
+
5.times do |i|
|
27
|
+
i
|
28
|
+
end
|
29
|
+
"""
|
30
|
+
When I run "seeing_is_believing --number-of-captures 2 number_of_captures.rb"
|
31
|
+
Then stderr is empty
|
32
|
+
And stdout is:
|
33
|
+
"""
|
34
|
+
5.times do |i| # => 5
|
35
|
+
i # => 0, 1, ...
|
36
|
+
end # => 5
|
37
|
+
"""
|
38
|
+
And the exit status is 0
|
39
|
+
|
40
|
+
Scenario: --shebang with errors
|
41
|
+
When I run "seeing_is_believing --shebang not/a/thing not_a_file.rb"
|
42
|
+
Then stdout is empty
|
43
|
+
And stderr is:
|
44
|
+
"""
|
45
|
+
Error: not_a_file.rb does not exist!
|
46
|
+
Deprecated: `--shebang not/a/thing` SiB now uses the Ruby it was invoked with
|
47
|
+
"""
|
48
|
+
|
49
|
+
Scenario: --number-of-captures with errors
|
50
|
+
When I run "seeing_is_believing not_a_file.rb --number-of-captures 2"
|
51
|
+
Then stdout is empty
|
52
|
+
And stderr is:
|
53
|
+
"""
|
54
|
+
Error: not_a_file.rb does not exist!
|
55
|
+
Deprecated: `--number-of-captures 2` use --max-line-captures instead
|
56
|
+
"""
|
57
|
+
|
58
|
+
Scenario: --inherit-exit-status without errors
|
59
|
+
Given the file "deprecated_inherit_exit_status.rb" "exit 123"
|
60
|
+
When I run "seeing_is_believing deprecated_inherit_exit_status.rb --inherit-exit-status"
|
61
|
+
Then stdout is "exit 123"
|
62
|
+
And stderr is empty
|
63
|
+
And the exit status is 123
|
64
|
+
|
65
|
+
Scenario: --inherit-exit-status with errors
|
66
|
+
When I run "seeing_is_believing not_a_file.rb --inherit-exit-status"
|
67
|
+
Then stdout is empty
|
68
|
+
And stderr is:
|
69
|
+
"""
|
70
|
+
Error: not_a_file.rb does not exist!
|
71
|
+
Deprecated: `--inherit-exit-status` Dash has been removed for consistency, use --inherit-exitstatus
|
72
|
+
"""
|
data/features/errors.feature
CHANGED
@@ -51,29 +51,34 @@ Feature: Running the binary unsuccessfully
|
|
51
51
|
Scenario: Syntactically invalid file
|
52
52
|
Given the file "invalid_syntax.rb":
|
53
53
|
"""
|
54
|
-
'
|
54
|
+
'this is valid'
|
55
|
+
'this is not
|
55
56
|
"""
|
56
57
|
When I run "seeing_is_believing invalid_syntax.rb"
|
57
|
-
Then stderr
|
58
|
+
Then stderr is:
|
59
|
+
"""
|
60
|
+
Syntax Error: invalid_syntax.rb:2
|
61
|
+
unterminated string meets end of file
|
62
|
+
"""
|
58
63
|
And the exit status is 2
|
59
64
|
And stdout is empty
|
60
65
|
|
61
66
|
Scenario: Passing a nonexistent file
|
62
67
|
When I run "seeing_is_believing this_file_does_not_exist.rb"
|
63
|
-
Then stderr is "this_file_does_not_exist.rb does not exist!"
|
68
|
+
Then stderr is "Error: this_file_does_not_exist.rb does not exist!"
|
64
69
|
And the exit status is 2
|
65
70
|
And stdout is empty
|
66
71
|
|
67
72
|
Scenario: Passing unknown options
|
68
73
|
Given the file "some_file" "1"
|
69
74
|
When I run "seeing_is_believing --unknown-option"
|
70
|
-
Then stderr is '
|
75
|
+
Then stderr is 'Error: --unknown-option is not an option, see the help screen (-h) for a list of options'
|
71
76
|
And the exit status is 2
|
72
77
|
And stdout is empty
|
73
78
|
|
74
|
-
Scenario:
|
75
|
-
When I run "seeing_is_believing --
|
76
|
-
Then stderr
|
79
|
+
Scenario: Reports deprecations with errors
|
80
|
+
When I run "seeing_is_believing this_file_does_not_exist.rb --number-of-captures 10"
|
81
|
+
Then stderr includes "--number-of-captures 10"
|
77
82
|
And the exit status is 2
|
78
83
|
And stdout is empty
|
79
84
|
|
data/features/examples.feature
CHANGED
@@ -105,7 +105,7 @@ Feature: Running the binary successfully
|
|
105
105
|
def name
|
106
106
|
@name # => "Josh", "Rick"
|
107
107
|
end # => {{method_result :name}}
|
108
|
-
end
|
108
|
+
end # => {{method_result :name}}
|
109
109
|
|
110
110
|
User.new("Josh").name # => "Josh"
|
111
111
|
User.new("Rick").name # => "Rick"
|
@@ -163,11 +163,13 @@ Feature: Running the binary successfully
|
|
163
163
|
# !> goodbye
|
164
164
|
"""
|
165
165
|
|
166
|
-
Scenario: Respects macros
|
166
|
+
Scenario: Respects macros / magic comments
|
167
167
|
Given the file "some_dir/uses_macros.rb":
|
168
168
|
"""
|
169
|
+
# encoding: EUC-JP
|
169
170
|
__FILE__
|
170
171
|
__LINE__
|
172
|
+
__ENCODING__
|
171
173
|
$stdout.puts "omg"
|
172
174
|
$stderr.puts "hi"
|
173
175
|
DATA.read
|
@@ -181,12 +183,14 @@ Feature: Running the binary successfully
|
|
181
183
|
And the exit status is 0
|
182
184
|
And stdout is:
|
183
185
|
"""
|
186
|
+
# encoding: EUC-JP
|
184
187
|
__FILE__ # => "some_dir/uses_macros.rb"
|
185
|
-
__LINE__ # =>
|
188
|
+
__LINE__ # => 3
|
189
|
+
__ENCODING__ # => #<Encoding:EUC-JP>
|
186
190
|
$stdout.puts "omg" # => nil
|
187
191
|
$stderr.puts "hi" # => nil
|
188
192
|
DATA.read # => "1\n2\n"
|
189
|
-
__LINE__ # =>
|
193
|
+
__LINE__ # => 8
|
190
194
|
|
191
195
|
# >> omg
|
192
196
|
|
@@ -218,3 +222,138 @@ Feature: Running the binary successfully
|
|
218
222
|
Then stderr is empty
|
219
223
|
And the exit status is 0
|
220
224
|
And stdout is "1 + 1 # => 2"
|
225
|
+
|
226
|
+
Scenario: Can exec another process, it records as many lines get exec'd, passes file descriptors, records exec'd output data
|
227
|
+
Given the stdin content "pass this through"
|
228
|
+
And the file "calls_exec.rb":
|
229
|
+
"""
|
230
|
+
$stdout.puts "First program to stdout"
|
231
|
+
$stderr.puts "First program to stderr"
|
232
|
+
exec 'ruby', '-e', '
|
233
|
+
$stdout.puts "Stdin passed to second program: #{gets.inspect}"
|
234
|
+
$stderr.puts "Exec\'d file to stderr"
|
235
|
+
$stdout.flush
|
236
|
+
exec "ruby", "-v"
|
237
|
+
'
|
238
|
+
"""
|
239
|
+
When I run "seeing_is_believing calls_exec.rb"
|
240
|
+
Then stderr is empty
|
241
|
+
And stdout is:
|
242
|
+
"""
|
243
|
+
$stdout.puts "First program to stdout" # => nil
|
244
|
+
$stderr.puts "First program to stderr" # => nil
|
245
|
+
exec 'ruby', '-e', '
|
246
|
+
$stdout.puts "Stdin passed to second program: #{gets.inspect}"
|
247
|
+
$stderr.puts "Exec\'d file to stderr"
|
248
|
+
$stdout.flush
|
249
|
+
exec "ruby", "-v"
|
250
|
+
'
|
251
|
+
|
252
|
+
# >> First program to stdout
|
253
|
+
# >> Stdin passed to second program: "pass this through"
|
254
|
+
# >> {{`ruby -v`.chomp}}
|
255
|
+
|
256
|
+
# !> First program to stderr
|
257
|
+
# !> Exec'd file to stderr
|
258
|
+
"""
|
259
|
+
And the exit status is 0
|
260
|
+
|
261
|
+
|
262
|
+
Scenario: Implicit regexp conditional
|
263
|
+
Given the stdin content "abc"
|
264
|
+
And the file "implicit_regex_conditional.rb":
|
265
|
+
"""
|
266
|
+
gets
|
267
|
+
if /(.)c/
|
268
|
+
$1
|
269
|
+
end
|
270
|
+
"""
|
271
|
+
When I run "seeing_is_believing implicit_regex_conditional.rb"
|
272
|
+
Then stdout is:
|
273
|
+
"""
|
274
|
+
gets # => "abc"
|
275
|
+
if /(.)c/ # => 1
|
276
|
+
$1 # => "b"
|
277
|
+
end # => "b"
|
278
|
+
"""
|
279
|
+
|
280
|
+
|
281
|
+
Scenario: BEGIN and END blocks
|
282
|
+
Given the file "BEGIN_and_END.rb":
|
283
|
+
"""
|
284
|
+
# encoding: utf-8
|
285
|
+
p [:a, __LINE__]
|
286
|
+
BEGIN {
|
287
|
+
p [:b, __LINE__]
|
288
|
+
BEGIN { p [:c, __LINE__] }
|
289
|
+
}
|
290
|
+
p [:d, __LINE__]
|
291
|
+
END {
|
292
|
+
p [:e, __LINE__]
|
293
|
+
}
|
294
|
+
p [:f, __LINE__]
|
295
|
+
BEGIN { p [:g, __LINE__] }
|
296
|
+
END { p [:h, __LINE__] }
|
297
|
+
p [:i, __LINE__]
|
298
|
+
"π"
|
299
|
+
"""
|
300
|
+
When I run "seeing_is_believing BEGIN_and_END.rb"
|
301
|
+
Then stderr is empty
|
302
|
+
Then stdout is:
|
303
|
+
"""
|
304
|
+
# encoding: utf-8
|
305
|
+
p [:a, __LINE__] # => [:a, 2]
|
306
|
+
BEGIN {
|
307
|
+
p [:b, __LINE__] # => [:b, 4]
|
308
|
+
BEGIN { p [:c, __LINE__] } # => [:c, 5]
|
309
|
+
}
|
310
|
+
p [:d, __LINE__] # => [:d, 7]
|
311
|
+
END {
|
312
|
+
p [:e, __LINE__] # => [:e, 9]
|
313
|
+
}
|
314
|
+
p [:f, __LINE__] # => [:f, 11]
|
315
|
+
BEGIN { p [:g, __LINE__] } # => [:g, 12]
|
316
|
+
END { p [:h, __LINE__] } # => [:h, 13]
|
317
|
+
p [:i, __LINE__] # => [:i, 14]
|
318
|
+
"π" # => "π"
|
319
|
+
|
320
|
+
# >> [:c, 5]
|
321
|
+
# >> [:b, 4]
|
322
|
+
# >> [:g, 12]
|
323
|
+
# >> [:a, 2]
|
324
|
+
# >> [:d, 7]
|
325
|
+
# >> [:f, 11]
|
326
|
+
# >> [:i, 14]
|
327
|
+
# >> [:h, 13]
|
328
|
+
# >> [:e, 9]
|
329
|
+
"""
|
330
|
+
When I run "seeing_is_believing BEGIN_and_END.rb --xmpfilter-style"
|
331
|
+
Then stderr is empty
|
332
|
+
Then stdout is:
|
333
|
+
"""
|
334
|
+
# encoding: utf-8
|
335
|
+
p [:a, __LINE__]
|
336
|
+
BEGIN {
|
337
|
+
p [:b, __LINE__]
|
338
|
+
BEGIN { p [:c, __LINE__] }
|
339
|
+
}
|
340
|
+
p [:d, __LINE__]
|
341
|
+
END {
|
342
|
+
p [:e, __LINE__]
|
343
|
+
}
|
344
|
+
p [:f, __LINE__]
|
345
|
+
BEGIN { p [:g, __LINE__] }
|
346
|
+
END { p [:h, __LINE__] }
|
347
|
+
p [:i, __LINE__]
|
348
|
+
"π"
|
349
|
+
|
350
|
+
# >> [:c, 5]
|
351
|
+
# >> [:b, 4]
|
352
|
+
# >> [:g, 12]
|
353
|
+
# >> [:a, 2]
|
354
|
+
# >> [:d, 7]
|
355
|
+
# >> [:f, 11]
|
356
|
+
# >> [:i, 14]
|
357
|
+
# >> [:h, 13]
|
358
|
+
# >> [:e, 9]
|
359
|
+
"""
|