live_ast 0.2.3 → 0.5.0
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.
- data/CHANGES.rdoc +13 -0
- data/MANIFEST +1 -3
- data/README.rdoc +47 -49
- data/Rakefile +7 -8
- data/devel/jumpstart.rb +101 -192
- data/lib/live_ast/base.rb +6 -1
- data/lib/live_ast/linker.rb +1 -1
- data/lib/live_ast/to_ruby.rb +1 -12
- data/lib/live_ast/version.rb +1 -1
- data/test/ast_eval_feature_test.rb +1 -1
- data/test/ast_load_feature_test.rb +1 -1
- data/test/backtrace_test.rb +1 -1
- data/test/covert_define_method_test.rb +2 -2
- data/test/def_test.rb +1 -1
- data/test/define_method_test.rb +1 -1
- data/test/define_singleton_method_test.rb +1 -1
- data/test/encoding_test.rb +3 -3
- data/test/error_test.rb +4 -4
- data/test/eval_test.rb +1 -1
- data/test/flush_cache_test.rb +4 -4
- data/test/lambda_test.rb +1 -1
- data/test/load_path_test.rb +3 -3
- data/test/load_test.rb +2 -2
- data/test/{shared/main.rb → main.rb} +26 -16
- data/test/noninvasive_test.rb +1 -1
- data/test/readme_test.rb +10 -8
- data/test/recursive_eval_test.rb +1 -1
- data/test/redefine_method_test.rb +1 -1
- data/test/reload_test.rb +1 -1
- data/test/stdlib_test.rb +1 -1
- data/test/thread_test.rb +1 -1
- data/test/to_ast_feature_test.rb +1 -1
- data/test/to_ruby_feature_test.rb +1 -1
- data/test/to_ruby_test.rb +4 -2
- metadata +8 -95
- data/lib/live_ast/parser.rb +0 -48
- data/test/shared/ast_generators.rb +0 -124
data/devel/jumpstart.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
|
2
2
|
class Jumpstart
|
3
|
-
class
|
3
|
+
class Installer
|
4
4
|
def initialize
|
5
5
|
require 'fileutils'
|
6
6
|
require 'rbconfig'
|
@@ -219,17 +219,6 @@ class Jumpstart
|
|
219
219
|
}
|
220
220
|
contents
|
221
221
|
end
|
222
|
-
|
223
|
-
def replace_file(file)
|
224
|
-
old_contents = File.read(file)
|
225
|
-
new_contents = yield(old_contents)
|
226
|
-
if old_contents != new_contents
|
227
|
-
File.open(file, "wb") { |output|
|
228
|
-
output.print(new_contents)
|
229
|
-
}
|
230
|
-
end
|
231
|
-
new_contents
|
232
|
-
end
|
233
222
|
end
|
234
223
|
|
235
224
|
module InstanceEvalWithArgs
|
@@ -264,7 +253,6 @@ class Jumpstart
|
|
264
253
|
$LOAD_PATH.unshift File.dirname(__FILE__) + '/../lib'
|
265
254
|
|
266
255
|
require 'rubygems/package_task'
|
267
|
-
require 'rake/clean'
|
268
256
|
|
269
257
|
@project_name = project_name
|
270
258
|
|
@@ -272,7 +260,7 @@ class Jumpstart
|
|
272
260
|
|
273
261
|
self.class.instance_methods(false).select { |t|
|
274
262
|
t.to_s =~ %r!\Adefine_!
|
275
|
-
}.each { |method_name|
|
263
|
+
}.sort.each { |method_name|
|
276
264
|
send(method_name)
|
277
265
|
}
|
278
266
|
end
|
@@ -295,9 +283,9 @@ class Jumpstart
|
|
295
283
|
|
296
284
|
attribute :version do
|
297
285
|
catch :bail do
|
298
|
-
if File.
|
286
|
+
if File.file?(version_file = "./lib/#{name}/version.rb")
|
299
287
|
require version_file
|
300
|
-
elsif File.
|
288
|
+
elsif File.file?("./lib/#{name}.rb")
|
301
289
|
require name
|
302
290
|
else
|
303
291
|
throw :bail
|
@@ -377,43 +365,46 @@ class Jumpstart
|
|
377
365
|
end
|
378
366
|
|
379
367
|
attribute :files do
|
380
|
-
if File.
|
368
|
+
if File.file? manifest_file
|
381
369
|
File.read(manifest_file).split("\n")
|
382
|
-
|
383
|
-
|
384
|
-
end
|
370
|
+
elsif source_control?
|
371
|
+
IO.popen("git ls-files") { |pipe| pipe.read.split "\n" }
|
372
|
+
end.to_a + [manifest_file] + generated_files
|
373
|
+
end
|
374
|
+
|
375
|
+
def files_in_require_paths
|
376
|
+
require_paths.inject([]) { |acc, dir|
|
377
|
+
acc + Dir.glob("#{dir}/**/*.rb")
|
378
|
+
}
|
385
379
|
end
|
386
380
|
|
387
381
|
attribute :rdoc_files do
|
388
|
-
|
382
|
+
files_in_require_paths
|
389
383
|
end
|
390
384
|
|
391
|
-
attribute :extra_rdoc_files do
|
392
|
-
if File.exist?(readme_file)
|
393
|
-
[readme_file]
|
394
|
-
else
|
395
|
-
[]
|
396
|
-
end
|
397
|
-
end
|
398
|
-
|
399
385
|
attribute :rdoc_title do
|
400
386
|
"#{name}: #{summary}"
|
401
387
|
end
|
402
388
|
|
389
|
+
attribute :require_paths do
|
390
|
+
["lib"]
|
391
|
+
end
|
392
|
+
|
403
393
|
attribute :rdoc_options do
|
404
|
-
if File.
|
394
|
+
if File.file?(readme_file)
|
405
395
|
["--main", readme_file]
|
406
396
|
else
|
407
397
|
[]
|
408
398
|
end + [
|
409
399
|
"--title", rdoc_title,
|
410
|
-
] + (
|
400
|
+
] + (files_in_require_paths - rdoc_files).inject(Array.new) {
|
401
|
+
|acc, file|
|
411
402
|
acc + ["--exclude", file]
|
412
403
|
}
|
413
404
|
end
|
414
405
|
|
415
|
-
attribute :
|
416
|
-
[]
|
406
|
+
attribute :extra_rdoc_files do
|
407
|
+
File.file?(readme_file) ? [readme_file] : []
|
417
408
|
end
|
418
409
|
|
419
410
|
attribute :browser do
|
@@ -426,7 +417,7 @@ class Jumpstart
|
|
426
417
|
end
|
427
418
|
|
428
419
|
attribute :gemspec do
|
429
|
-
Gem::Specification.new
|
420
|
+
Gem::Specification.new do |g|
|
430
421
|
g.has_rdoc = true
|
431
422
|
%w[
|
432
423
|
name
|
@@ -436,26 +427,25 @@ class Jumpstart
|
|
436
427
|
version
|
437
428
|
description
|
438
429
|
files
|
439
|
-
extra_rdoc_files
|
440
430
|
rdoc_options
|
431
|
+
extra_rdoc_files
|
432
|
+
require_paths
|
441
433
|
].each { |param|
|
442
434
|
value = send(param) and (
|
443
435
|
g.send("#{param}=", value)
|
444
436
|
)
|
445
437
|
}
|
446
438
|
|
447
|
-
if url
|
448
|
-
g.homepage = url
|
449
|
-
end
|
439
|
+
g.homepage = url if url
|
450
440
|
|
451
|
-
|
441
|
+
dependencies.each { |dep|
|
452
442
|
g.add_dependency(*dep)
|
453
443
|
}
|
454
444
|
|
455
|
-
|
445
|
+
development_dependencies.each { |dep|
|
456
446
|
g.add_development_dependency(*dep)
|
457
447
|
}
|
458
|
-
|
448
|
+
end
|
459
449
|
end
|
460
450
|
|
461
451
|
attribute :readme_contents do
|
@@ -505,57 +495,53 @@ class Jumpstart
|
|
505
495
|
}
|
506
496
|
|
507
497
|
attribute :url do
|
508
|
-
|
509
|
-
readme_contents.match(%r!^\*.*?(http://\S+)!)[1]
|
510
|
-
rescue
|
511
|
-
"http://#{github_user}.github.com/#{name}"
|
512
|
-
end
|
498
|
+
"http://#{github_user}.github.com/#{name}"
|
513
499
|
end
|
514
500
|
|
515
501
|
attribute :github_user do
|
516
|
-
"
|
517
|
-
end
|
518
|
-
|
519
|
-
attribute :extra_deps do
|
520
|
-
[]
|
502
|
+
raise "github_user not set"
|
521
503
|
end
|
522
504
|
|
523
|
-
attribute :
|
524
|
-
|
505
|
+
attribute :rubyforge_info do
|
506
|
+
nil
|
525
507
|
end
|
526
508
|
|
527
509
|
attribute :authors do
|
528
|
-
|
510
|
+
developers.map { |d| d[0] }
|
529
511
|
end
|
530
512
|
|
531
513
|
attribute :email do
|
532
|
-
|
514
|
+
developers.map { |d| d[1] }
|
533
515
|
end
|
534
516
|
|
535
|
-
|
536
|
-
|
537
|
-
self.email << email
|
517
|
+
attribute :dependencies do
|
518
|
+
[]
|
538
519
|
end
|
539
520
|
|
540
|
-
|
541
|
-
|
521
|
+
attribute :development_dependencies do
|
522
|
+
[]
|
523
|
+
end
|
524
|
+
|
525
|
+
attribute :developers do
|
526
|
+
[]
|
542
527
|
end
|
543
528
|
|
544
529
|
def define_clean
|
545
|
-
|
530
|
+
require 'rake/clean'
|
531
|
+
task :clean do
|
546
532
|
Rake::Task[:clobber].invoke
|
547
533
|
end
|
548
534
|
end
|
549
535
|
|
550
536
|
def define_package
|
551
|
-
|
552
|
-
|
537
|
+
if source_control?
|
538
|
+
task manifest_file do
|
539
|
+
create_manifest
|
540
|
+
end
|
541
|
+
CLEAN.add manifest_file
|
542
|
+
task :package => :clean
|
543
|
+
Gem::PackageTask.new(gemspec).define
|
553
544
|
end
|
554
|
-
CLEAN.include manifest_file
|
555
|
-
task :package => :clean
|
556
|
-
Gem::PackageTask.new(gemspec) { |t|
|
557
|
-
t.need_tar = true
|
558
|
-
}
|
559
545
|
end
|
560
546
|
|
561
547
|
def define_spec
|
@@ -598,21 +584,18 @@ class Jumpstart
|
|
598
584
|
task :prerelease => [:spec, :spec_deps]
|
599
585
|
task :default => :spec
|
600
586
|
|
601
|
-
CLEAN.
|
587
|
+
CLEAN.add spec_output_dir
|
602
588
|
end
|
603
589
|
end
|
604
590
|
|
605
|
-
def ruby_18?
|
606
|
-
RUBY_VERSION =~ %r!\A1\.8!
|
607
|
-
end
|
608
|
-
|
609
591
|
def define_test
|
610
592
|
unless test_files.empty?
|
611
593
|
desc "run tests"
|
612
594
|
task :test do
|
613
|
-
test_files.each { |file|
|
614
|
-
|
615
|
-
|
595
|
+
test_files.each { |file| require file }
|
596
|
+
|
597
|
+
# if we use at_exit hook instead, it won't run before :release
|
598
|
+
MiniTest::Unit.new.run ARGV
|
616
599
|
end
|
617
600
|
|
618
601
|
desc "run tests with coverage"
|
@@ -625,7 +608,7 @@ class Jumpstart
|
|
625
608
|
}
|
626
609
|
end
|
627
610
|
else
|
628
|
-
task :full_test do
|
611
|
+
task :full_test do
|
629
612
|
rm_rf cov_dir
|
630
613
|
require 'simplecov'
|
631
614
|
SimpleCov.start do
|
@@ -657,7 +640,7 @@ class Jumpstart
|
|
657
640
|
task :prerelease => [:test, :test_deps]
|
658
641
|
task :default => :test
|
659
642
|
|
660
|
-
CLEAN.
|
643
|
+
CLEAN.add cov_dir
|
661
644
|
end
|
662
645
|
end
|
663
646
|
|
@@ -668,7 +651,6 @@ class Jumpstart
|
|
668
651
|
require 'rdoc/rdoc'
|
669
652
|
args = (
|
670
653
|
gemspec.rdoc_options +
|
671
|
-
extra_rdoc_options +
|
672
654
|
gemspec.require_paths.clone +
|
673
655
|
gemspec.extra_rdoc_files +
|
674
656
|
["-o", doc_dir]
|
@@ -691,112 +673,48 @@ class Jumpstart
|
|
691
673
|
end
|
692
674
|
|
693
675
|
def define_publish
|
694
|
-
|
695
|
-
|
696
|
-
|
697
|
-
|
698
|
-
|
699
|
-
|
700
|
-
|
701
|
-
|
702
|
-
|
703
|
-
|
704
|
-
|
705
|
-
|
706
|
-
|
676
|
+
if source_control?
|
677
|
+
desc "publish docs"
|
678
|
+
task :publish => [:clean, :check_directory, :doc] do
|
679
|
+
if rubyforge_info
|
680
|
+
user, project = rubyforge_info
|
681
|
+
Dir.chdir(doc_dir) do
|
682
|
+
sh "scp", "-r",
|
683
|
+
".",
|
684
|
+
"#{user}@rubyforge.org:/var/www/gforge-projects/#{project}"
|
685
|
+
end
|
686
|
+
end
|
687
|
+
git "branch", "-D", "gh-pages"
|
688
|
+
git "checkout", "--orphan", "gh-pages"
|
689
|
+
FileUtils.rm ".git/index"
|
690
|
+
git "clean", "-fdx", "-e", "doc"
|
691
|
+
Dir["doc/*"].each { |path|
|
692
|
+
FileUtils.mv path, "."
|
693
|
+
}
|
694
|
+
FileUtils.rmdir "doc"
|
695
|
+
git "add", "."
|
696
|
+
git "commit", "-m", "generated by rdoc"
|
697
|
+
git "push", "-f", "origin", "gh-pages"
|
698
|
+
end
|
707
699
|
end
|
708
700
|
end
|
709
701
|
|
710
702
|
def define_install
|
711
703
|
desc "direct install (no gem)"
|
712
704
|
task :install do
|
713
|
-
|
705
|
+
Installer.new.run([])
|
714
706
|
end
|
715
707
|
|
716
708
|
desc "direct uninstall (no gem)"
|
717
709
|
task :uninstall do
|
718
|
-
|
710
|
+
Installer.new.run(["--uninstall"])
|
719
711
|
end
|
720
712
|
end
|
721
713
|
|
722
|
-
def define_debug
|
723
|
-
runner = Class.new do
|
724
|
-
def comment_src_dst(on)
|
725
|
-
on ? ["", "#"] : ["#", ""]
|
726
|
-
end
|
727
|
-
|
728
|
-
def comment_regions(on, contents, start)
|
729
|
-
src, dst = comment_src_dst(on)
|
730
|
-
contents.gsub(%r!^(\s+)#{src}#{start}.*?^\1#{src}(\}|end)!m) { |chunk|
|
731
|
-
indent = $1
|
732
|
-
chunk.gsub(%r!^#{indent}#{src}!, "#{indent}#{dst}")
|
733
|
-
}
|
734
|
-
end
|
735
|
-
|
736
|
-
def comment_lines(on, contents, start)
|
737
|
-
src, dst = comment_src_dst(on)
|
738
|
-
contents.gsub(%r!^(\s*)#{src}#{start}!) {
|
739
|
-
$1 + dst + start
|
740
|
-
}
|
741
|
-
end
|
742
|
-
|
743
|
-
def debug_info(enable)
|
744
|
-
require 'find'
|
745
|
-
Find.find("lib", "test") { |path|
|
746
|
-
if path =~ %r!\.rb\Z!
|
747
|
-
replace_file(path) { |contents|
|
748
|
-
result = comment_regions(!enable, contents, "debug")
|
749
|
-
comment_lines(!enable, result, "trace")
|
750
|
-
}
|
751
|
-
end
|
752
|
-
}
|
753
|
-
end
|
754
|
-
end
|
755
|
-
|
756
|
-
desc "enable debug and trace calls"
|
757
|
-
task :debug_on do
|
758
|
-
runner.new.debug_info(true)
|
759
|
-
end
|
760
|
-
|
761
|
-
desc "disable debug and trace calls"
|
762
|
-
task :debug_off do
|
763
|
-
runner.new.debug_info(false)
|
764
|
-
end
|
765
|
-
end
|
766
|
-
|
767
|
-
def define_columns
|
768
|
-
desc "check for columns > 80"
|
769
|
-
task :check_columns do
|
770
|
-
Dir["**/*.rb"].each { |file|
|
771
|
-
File.read(file).scan(%r!^.{81}!) { |match|
|
772
|
-
unless match =~ %r!http://!
|
773
|
-
raise "#{file} greater than 80 columns: #{match}"
|
774
|
-
end
|
775
|
-
}
|
776
|
-
}
|
777
|
-
end
|
778
|
-
end
|
779
|
-
|
780
|
-
def define_comments
|
781
|
-
task :comments do
|
782
|
-
file = "comments.txt"
|
783
|
-
write_file(file) {
|
784
|
-
result = Array.new
|
785
|
-
(["Rakefile"] + Dir["**/*.{rb,rake}"]).each { |f|
|
786
|
-
File.read(f).scan(%r!\#[^\{].*$!) { |match|
|
787
|
-
result << match
|
788
|
-
}
|
789
|
-
}
|
790
|
-
result.join("\n")
|
791
|
-
}
|
792
|
-
CLEAN.include file
|
793
|
-
end
|
794
|
-
end
|
795
|
-
|
796
714
|
def define_check_directory
|
797
715
|
task :check_directory do
|
798
716
|
unless `git status` =~ %r!nothing to commit \(working directory clean\)!
|
799
|
-
raise "
|
717
|
+
raise "directory not clean"
|
800
718
|
end
|
801
719
|
end
|
802
720
|
end
|
@@ -819,24 +737,8 @@ class Jumpstart
|
|
819
737
|
end
|
820
738
|
end
|
821
739
|
|
822
|
-
def define_update_jumpstart
|
823
|
-
url = ENV["RUBY_JUMPSTART"] || "git://github.com/quix/jumpstart.git"
|
824
|
-
task :update_jumpstart do
|
825
|
-
git "clone", url
|
826
|
-
rm_rf "devel/jumpstart"
|
827
|
-
Dir["jumpstart/**/*.rb"].each { |source|
|
828
|
-
dest = source.sub(%r!\Ajumpstart/!, "devel/")
|
829
|
-
dest_dir = File.dirname(dest)
|
830
|
-
mkdir_p(dest_dir) unless File.directory?(dest_dir)
|
831
|
-
cp source, dest
|
832
|
-
}
|
833
|
-
rm_r "jumpstart"
|
834
|
-
git "commit", "devel", "-m", "update jumpstart"
|
835
|
-
end
|
836
|
-
end
|
837
|
-
|
838
740
|
def git(*args)
|
839
|
-
sh
|
741
|
+
sh "git", *args
|
840
742
|
end
|
841
743
|
|
842
744
|
def create_manifest
|
@@ -849,9 +751,9 @@ class Jumpstart
|
|
849
751
|
task :prerelease => [:clean, :check_directory, :ping, history_file]
|
850
752
|
|
851
753
|
task :finish_release do
|
852
|
-
|
853
|
-
git
|
854
|
-
|
754
|
+
git "tag", "#{name}-" + version.to_s
|
755
|
+
git "push", "--tags", "origin", "master"
|
756
|
+
sh "gem", "push", gem
|
855
757
|
end
|
856
758
|
|
857
759
|
task :release => [:prerelease, :package, :finish_release]
|
@@ -879,6 +781,14 @@ class Jumpstart
|
|
879
781
|
}
|
880
782
|
end
|
881
783
|
|
784
|
+
def ruby_18?
|
785
|
+
RUBY_VERSION =~ %r!\A1\.8!
|
786
|
+
end
|
787
|
+
|
788
|
+
def source_control?
|
789
|
+
File.directory? ".git"
|
790
|
+
end
|
791
|
+
|
882
792
|
class << self
|
883
793
|
include Util
|
884
794
|
include InstanceEvalWithArgs
|
@@ -971,8 +881,7 @@ class Jumpstart
|
|
971
881
|
|
972
882
|
def doc_to_test(file, *sections, &block)
|
973
883
|
jump = self
|
974
|
-
|
975
|
-
klass = Class.new test_class::Unit::TestCase do
|
884
|
+
klass = Class.new MiniTest::Unit::TestCase do
|
976
885
|
sections.each { |section|
|
977
886
|
define_method "test_#{file}_#{section}" do
|
978
887
|
if block
|
@@ -986,7 +895,7 @@ class Jumpstart
|
|
986
895
|
end
|
987
896
|
}
|
988
897
|
end
|
989
|
-
Object.const_set("#{
|
898
|
+
Object.const_set("Test#{file}".gsub(".", ""), klass)
|
990
899
|
end
|
991
900
|
end
|
992
901
|
end
|
data/lib/live_ast/base.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
require 'thread'
|
2
2
|
|
3
3
|
require 'live_ast/reader'
|
4
|
-
require 'live_ast/parser'
|
5
4
|
require 'live_ast/evaler'
|
6
5
|
require 'live_ast/linker'
|
7
6
|
require 'live_ast/loader'
|
@@ -11,6 +10,12 @@ module LiveAST
|
|
11
10
|
NATIVE_EVAL = Kernel.method(:eval) #:nodoc:
|
12
11
|
|
13
12
|
class << self
|
13
|
+
attr_writer :parser #:nodoc:
|
14
|
+
|
15
|
+
def parser #:nodoc:
|
16
|
+
@parser ||= require('live_ast_ruby_parser') && LiveASTRubyParser
|
17
|
+
end
|
18
|
+
|
14
19
|
#
|
15
20
|
# For use in noninvasive mode (<code>require 'live_ast/base'</code>).
|
16
21
|
#
|
data/lib/live_ast/linker.rb
CHANGED
data/lib/live_ast/to_ruby.rb
CHANGED
@@ -1,11 +1,9 @@
|
|
1
|
-
require 'ruby2ruby'
|
2
|
-
|
3
1
|
require 'live_ast/base'
|
4
2
|
|
5
3
|
[Method, UnboundMethod, Proc].each do |klass|
|
6
4
|
klass.class_eval do
|
7
5
|
def to_ruby #:nodoc:
|
8
|
-
|
6
|
+
LiveAST.parser::Unparser.unparse(LiveAST.ast(self))
|
9
7
|
end
|
10
8
|
end
|
11
9
|
end
|
@@ -13,23 +11,14 @@ end
|
|
13
11
|
class Method
|
14
12
|
# :method: to_ruby
|
15
13
|
# Generate ruby code which reflects the AST of this object.
|
16
|
-
#
|
17
|
-
# Defined by <code>require 'live_ast/to_ruby'</code>. The ruby2ruby
|
18
|
-
# gem must be installed.
|
19
14
|
end
|
20
15
|
|
21
16
|
class UnboundMethod
|
22
17
|
# :method: to_ruby
|
23
18
|
# Generate ruby code which reflects the AST of this object.
|
24
|
-
#
|
25
|
-
# Defined by <code>require 'live_ast/to_ruby'</code>. The ruby2ruby
|
26
|
-
# gem must be installed.
|
27
19
|
end
|
28
20
|
|
29
21
|
class Proc
|
30
22
|
# :method: to_ruby
|
31
23
|
# Generate ruby code which reflects the AST of this object.
|
32
|
-
#
|
33
|
-
# Defined by <code>require 'live_ast/to_ruby'</code>. The ruby2ruby
|
34
|
-
# gem must be installed.
|
35
24
|
end
|
data/lib/live_ast/version.rb
CHANGED
data/test/backtrace_test.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require_relative '
|
1
|
+
require_relative 'main'
|
2
2
|
|
3
3
|
class CovertDefineMethodTest < RegularTest
|
4
4
|
DEFINE = lambda do
|
@@ -17,7 +17,7 @@ class CovertDefineMethodTest < RegularTest
|
|
17
17
|
DEFINE.call
|
18
18
|
assert_equal 77, A.new.h(33, 44)
|
19
19
|
|
20
|
-
assert_equal
|
20
|
+
assert_equal binop_define_method(:h, :+, :my_def),
|
21
21
|
A.instance_method(:h).to_ast
|
22
22
|
end
|
23
23
|
end
|
data/test/def_test.rb
CHANGED
data/test/define_method_test.rb
CHANGED
data/test/encoding_test.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require_relative '
|
1
|
+
require_relative 'main'
|
2
2
|
|
3
3
|
require_relative 'encoding_test/default.rb'
|
4
4
|
require_relative 'encoding_test/usascii.rb'
|
@@ -44,10 +44,10 @@ class AllEncodingTest < RegularTest
|
|
44
44
|
end
|
45
45
|
|
46
46
|
def test_bad
|
47
|
-
orig =
|
47
|
+
orig = assert_raises ArgumentError do
|
48
48
|
require "./test/encoding_test/bad.rb"
|
49
49
|
end
|
50
|
-
live =
|
50
|
+
live = assert_raises ArgumentError do
|
51
51
|
LiveAST.load "./test/encoding_test/bad.rb"
|
52
52
|
end
|
53
53
|
# inconsistent punctuation from Ruby
|
data/test/error_test.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
|
-
require_relative '
|
1
|
+
require_relative 'main'
|
2
2
|
|
3
3
|
class ErrorTest < RegularTest
|
4
4
|
def test_multiple_lambda_same_line
|
5
5
|
a = lambda { } ; b = lambda { }
|
6
6
|
|
7
|
-
|
7
|
+
assert_raises LiveAST::MultipleDefinitionsOnSameLineError do
|
8
8
|
a.to_ast
|
9
9
|
end
|
10
10
|
end
|
@@ -17,13 +17,13 @@ class ErrorTest < RegularTest
|
|
17
17
|
|
18
18
|
def test_multi_defs
|
19
19
|
DEFINE_A.call
|
20
|
-
|
20
|
+
assert_raises LiveAST::MultipleDefinitionsOnSameLineError do
|
21
21
|
A.instance_method(:f).to_ast
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
25
|
def test_ast_not_found
|
26
|
-
|
26
|
+
assert_raises LiveAST::NoSourceError do
|
27
27
|
File.method(:open).to_ast
|
28
28
|
end
|
29
29
|
end
|
data/test/eval_test.rb
CHANGED