Sha256: ea9fc86e54b35228f85fa40546d33504aa43acbd88e0e38eeac5eeb9c3d10422
Contents?: true
Size: 1.87 KB
Versions: 27
Compression:
Stored size: 1.87 KB
Contents
describe 'Regexp#match' do describe 'when pos is not specified' do it 'calls .exec only once on the current object' do regexp = /test/ calls = 0 %x( regexp._exec = regexp.exec; regexp.exec = function(str) { var match = this._exec(str); calls++; return match; } ) result = regexp.match('test test') calls.should == 1 result.begin(0).should == 0 result[0].should == 'test' end end describe 'when pos is specified' do it 'does not call .exec on the current object' do regexp = /test/ calls = 0 %x( regexp._exec = regexp.exec; regexp.exec = function(str) { var match = this._exec(str); calls++; return match; } ) result = regexp.match('test test', 1) calls.should == 0 result[0].should == 'test' result.begin(0).should == 5 end end end describe 'Regexp#match?' do describe 'when pos is not specified' do it 'calls .test on the current object' do regexp = /test/ calls = 0 %x( regexp._test = regexp.test; regexp.test = function(str) { var verdict = this._test(str); calls++; return verdict; } ) result = regexp.match?('test test') calls.should == 1 result.should == true end end describe 'when pos is specified' do it 'does not call .test on the current object' do regexp = /test/ calls = 0 %x( regexp._test = regexp.test; regexp.test = function(str) { var verdict = this._test(str); calls++; return verdict; } ) result = regexp.match?('test test', 1) calls.should == 0 # FIXME pos is not yet supported by Opal's Regexp#match? #result.should == true end end end
Version data entries
27 entries across 27 versions & 1 rubygems