403Webshell
Server IP : 66.29.132.122  /  Your IP : 52.15.72.32
Web Server : LiteSpeed
System : Linux business142.web-hosting.com 4.18.0-553.lve.el8.x86_64 #1 SMP Mon May 27 15:27:34 UTC 2024 x86_64
User : admazpex ( 531)
PHP Version : 7.2.34
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /proc/self/root/opt/cpanel/ea-ruby27/src/passenger-release-6.0.23/test/ruby/utils/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /proc/self/root/opt/cpanel/ea-ruby27/src/passenger-release-6.0.23/test/ruby/utils/strscan_spec.rb
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
PhusionPassenger.require_passenger_lib 'utils/strscan'

module PhusionPassenger

describe Utils::StringScanner do
  def new_scanner(data)
    Utils::StringScanner.new(data)
  end

  specify '#pos is initially 0' do
    scanner = new_scanner('ab')
    expect(scanner.pos).to eq(0)
  end

  specify '#matched is initially nil' do
    scanner = new_scanner('ab')
    expect(scanner.matched).to be_nil
  end

  describe '#getch' do
    it 'gets the next character and increments pos' do
      scanner = new_scanner('ab')
      expect(scanner.getch).to eq('a')
      expect(scanner.matched).to eq('a')
      expect(scanner.pos).to eq(1)
      expect(scanner.getch).to eq('b')
      expect(scanner.matched).to eq('b')
      expect(scanner.pos).to eq(2)
    end

    specify 'when data is empty, it returns nil and does not increment pos' do
      scanner = new_scanner('')
      expect(scanner.getch).to be_nil
      expect(scanner.matched).to be_nil
      expect(scanner.pos).to eq(0)
    end

    specify 'upon reaching EOS, it returns nil and does not increment pos' do
      scanner = new_scanner('a')
      scanner.getch
      expect(scanner.getch).to be_nil
      expect(scanner.matched).to be_nil
      expect(scanner.pos).to eq(1)
    end
  end

  describe '#scan' do
    describe 'if the pattern matches at the current pos' do
      it 'returns the match and increments pos' do
        scanner = new_scanner('aaaax')
        expect(scanner.scan(/a+/)).to eq('aaaa')
        expect(scanner.matched).to eq('aaaa')
        expect(scanner.pos).to eq(4)
        expect(scanner.scan(/x+/)).to eq('x')
        expect(scanner.matched).to eq('x')
        expect(scanner.pos).to eq(5)
      end
    end

    describe 'if the pattern does not match at the current pos' do
      it 'returns nil and does not increment pos' do
        scanner = new_scanner('aaaax')
        expect(scanner.scan(/x+/)).to be_nil
        expect(scanner.matched).to be_nil
        expect(scanner.pos).to eq(0)

        scanner.scan(/a+/)

        expect(scanner.scan(/y+/)).to be_nil
        expect(scanner.matched).to be_nil
        expect(scanner.pos).to eq(4)
      end
    end

    it 'scans across newlines' do
      scanner = new_scanner("a\na")
      expect(scanner.scan(/[a\s]+/)).to eq("a\na")
      expect(scanner.matched).to eq("a\na")
      expect(scanner.pos).to eq(3)
    end
  end
end

end

Youez - 2016 - github.com/yon3zu
LinuXploit