Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: opal/opal
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 7466416ecba7
Choose a base ref
...
head repository: opal/opal
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: d2c2cc1c9dd8
Choose a head ref
  • 4 commits
  • 6 files changed
  • 1 contributor

Commits on Jun 11, 2014

  1. Add another String#sub spec

    elia committed Jun 11, 2014
    Copy the full SHA
    14109ad View commit details

Commits on Jun 13, 2014

  1. Copy the full SHA
    869b318 View commit details
  2. Copy the full SHA
    1075cc8 View commit details

Commits on Jun 14, 2014

  1. Copy the full SHA
    d2c2cc1 View commit details
Showing with 73 additions and 20 deletions.
  1. +6 −0 Gemfile
  2. +58 −0 Guardfile
  3. +6 −17 README.md
  4. +0 −1 bin/opal-mspec
  5. +3 −1 opal/corelib/string.rb
  6. +0 −1 spec/filters/bugs/string.rb
6 changes: 6 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -12,3 +12,9 @@ group :repl do
gem 'therubyracer', :platform => :mri, :require => 'v8'
gem 'therubyrhino', :platform => :jruby
end

unless ENV['CI']
gem 'guard', require: false
gem 'rb-fsevent', require: false
gem 'terminal-notifier-guard'
end
58 changes: 58 additions & 0 deletions Guardfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
watch(%r{.*}) do |m|
path = m[0]
puts color("Searching specs for #{m[0]}...", :yellow)
case path
when %r{^spec/cli} then rspec path
when %r{^spec/corelib} then mspec path
when %r{^opal/corelib}
name = File.basename(path, '.rb')
mspec "spec/corelib/core/#{name}/**/*_spec.rb"
when %r{^lib/opal/(.*)\.rb$}
name = $1
specs = Dir["spec/cli/#{name}_spec.rb"]
rspec *specs
end
end


def mspec *paths
command = ['bundle', 'exec', './bin/opal-mspec', *paths.flatten]
result = time(:mspec, *paths) { system *command }
notify 'MSpec', result
end

def rspec *paths
command = ['bundle', 'exec', 'rspec', *paths.flatten]
result = time(:rspec, *paths) { system *command }
notify 'RSpec', result
end

def notify lib, result
if result
::Guard::Notifier.notify(
'Success ♥︎', title: "#{lib} results", image: :success, priority: 1
)
else
::Guard::Notifier.notify(
'Failed ♠︎', title: "#{lib} results", image: :failed, priority: 1
)
end
end

def color *args
Guard::UI.send :color, *args
end

def terminal_columns
cols = `tput cols 2> /dev/tty`.strip.to_i
($?.success? && cols.nonzero?) ? cols : 80
end

def time *titles
columns = terminal_columns
puts color("=== running: #{titles.join(' ')} ".ljust(columns,'='), :cyan)
s = Time.now
yield
t = (Time.now - s).to_f
puts color("=== time: #{t} seconds ".ljust(columns, '='), :cyan)
end
23 changes: 6 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -68,6 +68,12 @@ The test suite can be run using (requires [phantomjs][]):

This will command will run all RSpec and MSpec examples in sequence.

#### Automated runs

A `Guardfile` with decent mappings between specs and lib/corelib/stdlib files.
Run `bundle exec guard -i` to have it started.


### MSpec

[MSpec][] tests can be run with:
@@ -77,30 +83,13 @@ This will command will run all RSpec and MSpec examples in sequence.
Alternatively, you can just load up a rack instance using `rackup spec/config.ru`, and
visit `http://localhost:9292/` in any web browser.

#### Automated runs

[spectator][] can be used in an autotest fashion with this command

```shell
spectator .spectator-mspec # this will run MSpec examples only
```



### Rspec

[RSpec][] tests can be run with

$ rake rspec

#### Automated runs

[spectator][] can be used in an autotest fashion with this command

```shell
spectator # this will run RSpec examples only
```


## Code Overview

1 change: 0 additions & 1 deletion bin/opal-mspec
Original file line number Diff line number Diff line change
@@ -5,7 +5,6 @@ specs = ARGV.map do |s|
end
pattern = %Q{MSPEC_PATTERN="{#{specs.join(',')}}"} if specs.any?
command = [pattern, 'rake mspec'].compact.join(' ')
puts "Executing: #{command}"
exec command

# bundle exec mspec run -t './bin/opal -siconv -sfileutils -syaml -rfile -rprocess -Dwarning -I /Users/elia/Code/mspec/lib/ -I lib/ -rmspec/opal/mspec_fixes.rb ' spec/corelib/core/true/*
4 changes: 3 additions & 1 deletion opal/corelib/string.rb
Original file line number Diff line number Diff line change
@@ -768,7 +768,9 @@ def strip
return replace.replace(
/(^|[^\\])\\\\(\d)/g, '$1\\$2'
).replace(
/(^|[^\\])(?:(\\)\\)+\\\\(\d)/g, '$1$2\\$3'
/(^|[^\\])(\\\\)+\\\\(\d)/g, '$1$2\\$3'
).replace(
/(^|[^\\])(?:(\\)\\)+([^\\]|$)/g, '$1$2$3'
);
}
}
1 change: 0 additions & 1 deletion spec/filters/bugs/string.rb
Original file line number Diff line number Diff line change
@@ -192,7 +192,6 @@
fails "String#sub with pattern, replacement replaces \\' with everything after the current match"
fails "String#sub with pattern, replacement replaces \\+ with the last paren that actually matched"
fails "String#sub with pattern, replacement treats \\+ as an empty string if there was no captures"
fails "String#sub with pattern, replacement maps \\\\ in replacement to \\"
fails "String#sub with pattern, replacement sets $~ to MatchData of match and nil when there's none"
fails "String#sub with pattern and block sets $~ for access from the block"
fails "String#sub with pattern and block sets $~ to MatchData of last match and nil when there's none for access from outside"