code stringlengths 1 1.73M | language stringclasses 1
value |
|---|---|
require "rss-testcase"
require "rss/2.0"
module RSS
class TestParser20 < TestCase
def test_rss20
assert_parse(make_rss20(<<-EOR), :missing_tag, "channel", "rss")
EOR
assert_parse(make_rss20(<<-EOR), :nothing_raised)
#{make_channel20("")}
EOR
end
def test_cloud20
attrs = [
["d... | Ruby |
require "rss-testcase"
require "rss/maker"
module RSS
class TestMaker10 < TestCase
def test_supported?
assert(RSS::Maker.supported?("1.0"))
assert(RSS::Maker.supported?("rss1.0"))
assert(!RSS::Maker.supported?("1.1"))
assert(!RSS::Maker.supported?("rss1.1"))
end
def test_find_cl... | Ruby |
require "cgi"
require "rexml/document"
require "rss-testcase"
require "rss/1.0"
require "rss/image"
module RSS
class TestImage < TestCase
def setup
@prefix = "image"
@uri = "http://purl.org/rss/1.0/modules/image/"
@favicon_attrs = {
"rdf:about" => "http://www.kuro5hin.org/favicon.ic... | Ruby |
require "rss-testcase"
require "rss/maker"
module RSS
class TestMakerContent < TestCase
def setup
@uri = "http://purl.org/rss/1.0/modules/content/"
@elements = {
:encoded => "<em>ATTENTION</em>",
}
end
def test_rss10
rss = RSS::Maker.make("1.0") do |maker|
setu... | Ruby |
require "rss-testcase"
require "rss/maker"
module RSS
class TestMakerAtomEntry < TestCase
def test_supported?
assert(RSS::Maker.supported?("atom:entry"))
assert(RSS::Maker.supported?("atom1.0:entry"))
assert(!RSS::Maker.supported?("atom2.0:entry"))
end
def test_find_class
assert... | Ruby |
require "cgi"
require "rexml/document"
require "rss-testcase"
require "rss/1.0"
require "rss/2.0"
require "rss/trackback"
module RSS
class TestTrackBack < TestCase
def setup
@prefix = "trackback"
@uri = "http://madskills.com/public/xml/rss/module/trackback/"
@parents = %w(item)
@elem... | Ruby |
# $Id: test_scanf.rb 27786 2010-05-13 10:06:25Z nobu $
#
# scanf for Ruby
#
# Unit tests
#
require 'scanf.rb'
require 'test/unit'
require 'tmpdir'
# Comment out either of these lines to skip those tests.
class TestStringScanf < Test::Unit::TestCase;end
class TestIOScanf < Test::Unit::TestCase;end
module ScanfTests
... | Ruby |
# $Id: test_scanfblocks.rb 25189 2009-10-02 12:04:37Z akr $
#
# scanf for Ruby
#
# Some not very comprehensive tests of block behavior.
require 'test/unit'
require 'scanf'
require 'tmpdir'
class TestScanfBlock < Test::Unit::TestCase
def setup
@str = <<-EOS
Beethoven 1770
Bach 1685
Handel ... | Ruby |
# $Id: test_scanfio.rb 25426 2009-10-21 03:44:56Z nobu $
#
# scanf for Ruby
#
# Ad hoc tests of IO#scanf (needs to be expanded)
require "scanf"
class TestScanfIO < Test::Unit::TestCase
def test_io
fh = File.new(File.join(File.dirname(__FILE__), "data.txt"), "r")
assert_equal(0, fh.pos)
assert_equal(["t... | Ruby |
require 'test/unit'
require 'logger'
require 'tempfile'
class TestLoggerSeverity < Test::Unit::TestCase
def test_enum
logger_levels = Logger.constants
levels = ["WARN", "UNKNOWN", "INFO", "FATAL", "DEBUG", "ERROR"]
Logger::Severity.constants.each do |level|
assert(levels.include?(level.to_s))
... | Ruby |
begin
require 'net/https'
rescue LoadError
end
require 'test/unit'
class HTTPSProxyTest < Test::Unit::TestCase
def test_https_proxy_authentication
t = nil
TCPServer.open("127.0.0.1", 0) {|serv|
_, port, _, _ = serv.addr
t = Thread.new {
proxy = Net::HTTP.Proxy("127.0.0.1", port, 'user',... | Ruby |
require 'net/http'
require 'test/unit'
require 'stringio'
class HTTPResponseTest < Test::Unit::TestCase
def test_singleline_header
io = dummy_io(<<EOS.gsub(/\n/, "\r\n"))
HTTP/1.1 200 OK
Content-Length: 5
Connection: close
hello
EOS
res = Net::HTTPResponse.read_new(io)
assert_equal('5', res.header['cont... | Ruby |
require 'webrick'
begin
require "webrick/https"
rescue LoadError
# SSL features cannot be tested
end
require 'webrick/httpservlet/abstract'
module TestNetHTTPUtils
def start(&block)
new().start(&block)
end
def new
klass = Net::HTTP::Proxy(config('proxy_host'), config('proxy_port'))
http = klass.... | Ruby |
require 'net/http'
require 'test/unit'
class HTTPHeaderTest < Test::Unit::TestCase
class C
include Net::HTTPHeader
def initialize
initialize_http_header({})
end
attr_accessor :body
end
def setup
@c = C.new
end
def test_size
assert_equal 0, @c.size
@c['a'] = 'a'
assert... | Ruby |
require 'test/unit'
require 'net/http'
require 'stringio'
require_relative 'utils'
module Net
class TestBufferedIO < Test::Unit::TestCase
def test_eof?
s = StringIO.new
assert s.eof?
bio = BufferedIO.new(s)
assert_equal s, bio.io
assert_equal s.eof?, bio.eof?
end
end
end
| Ruby |
# $Id: test_http.rb 32192 2011-06-21 17:44:44Z nahi $
require 'test/unit'
require 'net/http'
require 'stringio'
require_relative 'utils'
module TestNetHTTP_version_1_1_methods
def test_s_get
assert_equal $test_net_http_data,
Net::HTTP.get(config('host'), '/', config('port'))
end
def test_head
... | Ruby |
require "test/unit"
begin
require 'net/https'
require 'stringio'
require 'timeout'
require File.expand_path("../../openssl/utils", File.dirname(__FILE__))
require File.expand_path("utils", File.dirname(__FILE__))
rescue LoadError
# should skip this test
end
class TestNetHTTPS < Test::Unit::TestCase
inclu... | Ruby |
require "net/imap"
require "test/unit"
class IMAPTest < Test::Unit::TestCase
CA_FILE = File.expand_path("cacert.pem", File.dirname(__FILE__))
SERVER_KEY = File.expand_path("server.key", File.dirname(__FILE__))
SERVER_CERT = File.expand_path("server.crt", File.dirname(__FILE__))
SERVER_ADDR = "127.0.0.1"
de... | Ruby |
require "net/imap"
require "test/unit"
class IMAPResponseParserTest < Test::Unit::TestCase
def setup
@do_not_reverse_lookup = Socket.do_not_reverse_lookup
Socket.do_not_reverse_lookup = true
if Net::IMAP.respond_to?(:max_flag_count)
@max_flag_count = Net::IMAP.max_flag_count
Net::IMAP.max_fla... | Ruby |
require 'net/pop'
require 'test/unit'
require 'digest/md5'
class TestPOP < Test::Unit::TestCase
def setup
@users = {'user' => 'pass' }
@ok_user = 'user'
@stamp_base = "#{$$}.#{Time.now.to_i}@localhost"
end
def test_pop_auth_ok
pop_test(false) do |pop|
assert_instance_of Net::POP3, pop
... | Ruby |
require 'net/smtp'
require 'minitest/autorun'
module Net
class TestSMTP < MiniTest::Unit::TestCase
def test_esmtp
smtp = Net::SMTP.new 'localhost', 25
assert smtp.esmtp
assert smtp.esmtp?
smtp.esmtp = 'omg'
assert_equal 'omg', smtp.esmtp
assert_equal 'omg', smtp.esmtp?
en... | Ruby |
require 'net/smtp'
require 'minitest/autorun'
module Net
class TestSSLSocket < MiniTest::Unit::TestCase
class MySMTP < SMTP
attr_accessor :fake_tcp, :fake_ssl
def tcp_socket address, port
fake_tcp
end
def ssl_socket socket, context
fake_ssl
end
end
require... | Ruby |
require 'net/smtp'
require 'minitest/autorun'
module Net
class SMTP
class TestResponse < MiniTest::Unit::TestCase
def test_capabilities
res = Response.parse("250-ubuntu-desktop\n250-PIPELINING\n250-SIZE 10240000\n250-VRFY\n250-ETRN\n250-STARTTLS\n250-ENHANCEDSTATUSCODES\n250 DSN\n")
capabi... | Ruby |
require 'test/unit'
require 'securerandom'
require 'tempfile'
# This testcase does NOT aim to test cryptographically strongness and randomness.
class TestSecureRandom < Test::Unit::TestCase
def setup
@it = SecureRandom
end
def test_s_random_bytes
assert_equal(16, @it.random_bytes.size)
assert_equal(... | Ruby |
require "monitor"
require "thread"
require "test/unit"
class TestMonitor < Test::Unit::TestCase
def setup
@monitor = Monitor.new
end
def test_enter
ary = []
queue = Queue.new
th = Thread.start {
queue.pop
@monitor.enter
for i in 6 .. 10
ary.push(i)
Thread.pass
... | Ruby |
require 'psych/helper'
module Psych
class TestOmap < TestCase
def test_parse_as_map
o = Psych.load "--- !!omap\na: 1\nb: 2"
assert_kind_of Psych::Omap, o
assert_equal 1, o['a']
assert_equal 2, o['b']
end
def test_self_referential
map = Psych::Omap.new
map['foo'] = 'ba... | Ruby |
require 'psych/helper'
module Psych
class Tagged
yaml_tag '!foo'
attr_accessor :baz
def initialize
@baz = 'bar'
end
end
class Foo
attr_accessor :parent
def initialize parent
@parent = parent
end
end
class TestObject < TestCase
def test_dump_with_tag
tag ... | Ruby |
require 'psych/helper'
module Psych
class TestStream < TestCase
def test_parse_partial
rb = Psych.parse("--- foo\n...\n--- `").to_ruby
assert_equal 'foo', rb
end
def test_load_partial
rb = Psych.load("--- foo\n...\n--- `")
assert_equal 'foo', rb
end
def test_parse_stream... | Ruby |
require 'psych/helper'
module Psych
class TestObjectReferences < TestCase
def test_range_has_references
assert_reference_trip 1..2
end
def test_module_has_references
assert_reference_trip Psych
end
def test_class_has_references
assert_reference_trip TestObjectReferences
en... | Ruby |
require 'psych/helper'
module Psych
class TestSerializeSubclasses < TestCase
class SomeObject
def initialize one, two
@one = one
@two = two
end
def == other
@one == other.instance_eval { @one } &&
@two == other.instance_eval { @two }
end
end
def... | Ruby |
require 'psych/helper'
module Psych
class TestCoder < TestCase
class InitApi
attr_accessor :implicit
attr_accessor :style
attr_accessor :tag
attr_accessor :a, :b, :c
def initialize
@a = 1
@b = 2
@c = 3
end
def init_with coder
@a = coder[... | Ruby |
require 'psych/helper'
module Psych
module Visitors
class TestDepthFirst < TestCase
class Collector < Struct.new(:calls)
def initialize(calls = [])
super
end
def call obj
calls << obj
end
end
def test_scalar
collector = Collector.new... | Ruby |
require 'psych/helper'
module Psych
module Visitors
class TestToRuby < TestCase
def setup
super
@visitor = ToRuby.new
end
def test_object
mapping = Nodes::Mapping.new nil, "!ruby/object"
mapping.children << Nodes::Scalar.new('foo')
mapping.children << No... | Ruby |
require 'psych/helper'
module Psych
module Visitors
class TestYAMLTree < TestCase
def setup
super
@v = Visitors::YAMLTree.new
end
def test_binary_formatting
gif = "GIF89a\f\x00\f\x00\x84\x00\x00\xFF\xFF\xF7\xF5\xF5\xEE\xE9\xE9\xE5fff\x00\x00\x00\xE7\xE7\xE7^^^\xF3\xF3\x... | Ruby |
require 'psych/helper'
module Psych
module Visitors
class TestEmitter < TestCase
def setup
super
@io = StringIO.new
@visitor = Visitors::Emitter.new @io
end
def test_options
io = StringIO.new
visitor = Visitors::Emitter.new io, :indentation => 3
... | Ruby |
require 'psych/helper'
module Psych
class TestClass < TestCase
module Foo
end
def test_cycle_anonymous_class
assert_raises(::TypeError) do
assert_cycle(Class.new)
end
end
def test_cycle_anonymous_module
assert_raises(::TypeError) do
assert_cycle(Module.new)
... | Ruby |
# -*- coding: utf-8 -*-
require 'psych/helper'
module Psych
class TestScalar < TestCase
def test_utf_8
assert_equal "日本語", Psych.load("--- 日本語")
end
end
end
| Ruby |
require 'psych/helper'
class ObjectWithInstanceVariables
attr_accessor :var1, :var2
end
class SubStringWithInstanceVariables < String
attr_accessor :var1
end
module Psych
class TestAliasAndAnchor < TestCase
def test_mri_compatibility
yaml = <<EOYAML
---
- &id001 !ruby/object {}
- *id001
- *id001
EOYAML... | Ruby |
require 'psych/helper'
module Psych
class TestDeprecated < TestCase
def teardown
Psych.domain_types.clear
end
class QuickEmitter
attr_reader :name
attr_reader :value
def initialize
@name = 'hello!!'
@value = 'Friday!'
end
def to_yaml opts = {}
... | Ruby |
require 'psych/helper'
class PsychStructWithIvar < Struct.new(:foo)
attr_reader :bar
def initialize *args
super
@bar = 'hello'
end
end
module Psych
class TestStruct < TestCase
class StructSubclass < Struct.new(:foo)
def initialize foo, bar
super(foo)
@bar = bar
end
... | Ruby |
require 'psych/helper'
module Psych
class TestArray < TestCase
class X < Array
end
class Y < Array
attr_accessor :val
end
def setup
super
@list = [{ :a => 'b' }, 'foo']
end
def test_another_subclass_with_attributes
y = Y.new.tap {|y| y.val = 1}
y << "foo" ... | Ruby |
require 'psych/helper'
module Psych
###
# Test booleans from YAML spec:
# http://yaml.org/type/bool.html
class TestBoolean < TestCase
%w{ yes Yes YES true True TRUE on On ON }.each do |truth|
define_method(:"test_#{truth}") do
assert_equal true, Psych.load("--- #{truth}")
end
end
... | Ruby |
require 'psych/helper'
module Psych
class TestNil < TestCase
def test_nil
yml = Psych.dump nil
assert_match(/--- \n(?:\.\.\.\n)?/, yml)
assert_nil Psych.load(yml)
end
def test_array_nil
yml = Psych.dump [nil]
assert_equal "---\n- \n", yml
assert_equal [nil], Psych.loa... | Ruby |
# -*- coding: utf-8 -*-
require 'psych/helper'
module Psych
class TestEncoding < TestCase
class EncodingCatcher < Handler
attr_reader :strings
def initialize
@strings = []
end
(Handler.instance_methods(true) -
Object.instance_methods).each do |m|
class_eval %{
... | Ruby |
require 'psych/helper'
module Psych
class TestJSONTree < TestCase
def test_string
assert_match(/"foo"/, Psych.to_json("foo"))
end
def test_symbol
assert_match(/"foo"/, Psych.to_json(:foo))
end
def test_nil
assert_match(/^null/, Psych.to_json(nil))
end
def test_int
... | Ruby |
require 'psych/helper'
module Psych
class TestDocument < TestCase
def setup
super
@stream = Psych.parse_stream(<<-eoyml)
%YAML 1.1
%TAG ! tag:tenderlovemaking.com,2009:
--- !fun
eoyml
@doc = @stream.children.first
end
def test_parse_tag
assert_equal([['!', 'tag:tenderlovema... | Ruby |
require 'psych/helper'
module Psych
module JSON
class TestStream < TestCase
def setup
@io = StringIO.new
@stream = Psych::JSON::Stream.new(@io)
@stream.start
end
def test_explicit_documents
@io = StringIO.new
@stream = Psych::JSON::Stream.new(@io... | Ruby |
require 'psych/helper'
require 'date'
module Psych
class TestScalarScanner < TestCase
attr_reader :ss
def setup
super
@ss = Psych::ScalarScanner.new
end
def test_scan_time
{ '2001-12-15T02:59:43.1Z' => Time.utc(2001, 12, 15, 02, 59, 43, 100000),
'2001-12-14t21:59:43.10-05:... | Ruby |
require 'psych/helper'
module Psych
class TestSymbol < TestCase
def test_cycle
assert_cycle :a
end
def test_stringy
assert_cycle :"1"
end
def test_load_quoted
assert_equal :"1", Psych.load("--- :'1'\n")
end
end
end
| Ruby |
# coding: utf-8
require 'psych/helper'
module Psych
class TestParser < TestCase
class EventCatcher < Handler
attr_accessor :parser
attr_reader :calls, :marks
def initialize
@parser = nil
@calls = []
@marks = []
end
(Handler.instance_methods(true) -
... | Ruby |
require 'psych/helper'
module Psych
class TestString < TestCase
class X < String
end
class Y < String
attr_accessor :val
end
def test_another_subclass_with_attributes
y = Psych.load Psych.dump Y.new("foo").tap {|y| y.val = 1}
assert_equal "foo", y
assert_equal Y, y.class... | Ruby |
require 'psych/helper'
module Psych
module Nodes
class TestEnumerable < TestCase
def test_includes_enumerable
yaml = '--- hello'
assert_equal 3, Psych.parse_stream(yaml).to_a.length
end
def test_returns_enumerator
yaml = '--- hello'
assert_equal 3, Psych.parse_s... | Ruby |
require 'minitest/autorun'
require 'stringio'
require 'tempfile'
require 'date'
module Psych
class TestCase < MiniTest::Unit::TestCase
#
# Convert between Psych and the object to verify correct parsing and
# emitting
#
def assert_to_yaml( obj, yaml )
assert_equal( obj, Psych::load( yaml ) )... | Ruby |
require 'psych/helper'
module Psych
###
# Test null from YAML spec:
# http://yaml.org/type/null.html
class TestNull < TestCase
def test_null_list
assert_equal [nil] * 5, Psych.load(<<-eoyml)
---
- ~
- null
-
- Null
- NULL
eoyml
end
end
end
| Ruby |
require 'psych/helper'
module Psych
class TestHash < TestCase
class X < Hash
end
def setup
super
@hash = { :a => 'b' }
end
def test_empty_subclass
assert_match "!ruby/hash:#{X}", Psych.dump(X.new)
x = Psych.load Psych.dump X.new
assert_equal X, x.class
end
... | Ruby |
require 'psych/helper'
module Psych
class TestMergeKeys < TestCase
def test_missing_merge_key
yaml = <<-eoyml
bar:
<< : *foo
eoyml
exp = assert_raises(Psych::BadAlias) { Psych.load yaml }
assert_match 'foo', exp.message
end
# [ruby-core:34679]
def test_merge_key
yaml ... | Ruby |
# -*- coding: utf-8 -*-
require 'psych/helper'
module Psych
class TestEmitter < TestCase
def setup
super
@out = StringIO.new('')
@emitter = Psych::Emitter.new @out
end
def test_line_width
assert_equal 0, @emitter.line_width
assert_equal 10, @emitter.line_width = 10
a... | Ruby |
require 'psych/helper'
require 'stringio'
require 'tempfile'
class TestPsych < Psych::TestCase
def teardown
Psych.domain_types.clear
end
def test_line_width
yml = Psych.dump('123456 7', { :line_width => 5 })
assert_match(/^\s*7/, yml)
end
def test_indent
yml = Psych.dump({:a => {'b' => 'c'... | Ruby |
require 'psych/helper'
module Psych
class TestSet < TestCase
def setup
super
@set = Psych::Set.new
@set['foo'] = 'bar'
@set['bar'] = 'baz'
end
def test_dump
assert_match(/!set/, Psych.dump(@set))
end
def test_roundtrip
assert_cycle(@set)
end
###
... | Ruby |
require 'psych/helper'
require 'yaml'
module Psych
class TestEngineManager < TestCase
def teardown
YAML::ENGINE.yamler = 'syck'
end
def test_bad_engine
assert_raises(ArgumentError) do
YAML::ENGINE.yamler = 'foooo'
end
end
def test_set_psych
YAML::ENGINE.yamler = 'psych'
... | Ruby |
# -*- mode: ruby; ruby-indent-level: 4; tab-width: 4 -*-
# vim:sw=4:ts=4
# $Id$
#
require 'psych/helper'
require 'ostruct'
# [ruby-core:01946]
module Psych_Tests
StructTest = Struct::new( :c )
end
class Psych_Unit_Tests < Psych::TestCase
def teardown
Psych.domain_types.clear
end
de... | Ruby |
require 'psych/helper'
module Psych
class TestException < TestCase
class Wups < Exception
attr_reader :foo, :bar
def initialize *args
super
@foo = 1
@bar = 2
end
end
def setup
super
@wups = Wups.new
end
def test_load_takes_file
ex = as... | Ruby |
require 'psych/helper'
module Psych
class TestToYamlProperties < MiniTest::Unit::TestCase
class Foo
attr_accessor :a, :b, :c
def initialize
@a = 1
@b = 2
@c = 3
end
def to_yaml_properties
[:@a, :@b]
end
end
def test_object_dump_yaml_properti... | Ruby |
require 'psych/helper'
module Psych
class TestStringTainted < TestCase
class Tainted < Handler
attr_reader :tc
def initialize tc
@tc = tc
end
def start_document version, tags, implicit
tags.flatten.each do |tag|
assert_taintedness tag
end
end
... | Ruby |
require 'psych/helper'
require 'date'
module Psych
class TestDateTime < TestCase
def test_string_tag
dt = DateTime.now
yaml = Psych.dump dt
assert_match(/DateTime/, yaml)
end
def test_round_trip
dt = DateTime.now
assert_cycle dt
end
end
end
| Ruby |
require 'psych/helper'
require 'bigdecimal'
module Psych
###
# Test numerics from YAML spec:
# http://yaml.org/type/float.html
# http://yaml.org/type/int.html
class TestNumeric < TestCase
def test_non_float_with_0
str = Psych.load('--- 090')
assert_equal '090', str
end
def test_big_d... | Ruby |
require 'psych/helper'
module Psych
class TestTreeBuilder < TestCase
def setup
super
@parser = Psych::Parser.new TreeBuilder.new
@parser.parse(<<-eoyml)
%YAML 1.1
---
- foo
- {
bar : &A !!str baz,
boo : *A
}
- *A
eoyml
@tree = @parser.handler.root
end
def test_stream
... | Ruby |
require "test/unit"
require "coverage"
require "tmpdir"
class TestCoverage < Test::Unit::TestCase
def test_result_without_start
assert_raise(RuntimeError) {Coverage.result}
end
def test_result_with_nothing
Coverage.start
result = Coverage.result
assert_kind_of(Hash, result)
result.each do |ke... | Ruby |
#!./miniruby -s
$:.unshift(File.expand_path("../..", __FILE__))
require 'win32/mkexports'
class Exports::Bcc < Exports
def forwarding(internal, export)
internal[/\A_?/]+export
end
def each_line(objs, &block)
objs.each do |obj|
opt = /\.(?:so|dll)\z/i =~ obj ? "-ee" : "-oiPUBDEF -oiPUBD32"
I... | Ruby |
#
# This test file concludes tests which point out known bugs.
# So all tests will cause failure.
#
| Ruby |
#!/usr/bin/ruby
# tool/update-deps assists you to update dependencies in common.mk.
# This script uses preprocessed source files (*.i) to extract
# dependencies.
# It is possible to generate *.i using gcc with -save-temps option as:
#
# ./configure CFLAGS='-save-temps'
# make all golf
#
# After that, tool/update-... | Ruby |
$file = ARGV[0]
$str = ARGF.read.sub(/^__END__.*\z/m, '')
puts '# ' + '-' * 70
puts "# target program: "
puts '# ' + '-' * 70
puts $str
puts '# ' + '-' * 70
$parsed = RubyVM::InstructionSequence.compile_file($file)
puts "# disasm result: "
puts '# ' + '-' * 70
puts $parsed.disasm
puts '# ' + '-' * 70
| Ruby |
#! ./miniruby
while gets
if ~/enum node_type \{/..~/^\};/
~/(NODE_.+),/ and puts(" case #{$1}:\n\treturn \"#{$1}\";")
end
end
| Ruby |
#! ./miniruby
def diff2index(cmd, *argv)
lines = []
path = nil
`#{cmd} #{argv.join(" ")}`.split(/\n/).each do |line|
case line
when /^Index: (\S*)/, /^diff --git [a-z]\/(\S*) [a-z]\/\1/
path = $1
when /^@@\s*-[,\d]+ +\+(\d+)[,\d]*\s*@@(?: +([A-Za-z_][A-Za-z_0-9 ]*[A-Za-z_0-9]))?/
line = $... | Ruby |
require './rbconfig'
require 'fileutils'
require 'pp'
Ruby = ENV['RUBY'] || RbConfig.ruby
#
OPTIONS = %w{
opt-direct-threaded-code
opt-basic-operations
opt-operands-unification
opt-instructions-unification
opt-inline-method-cache
opt-stack-caching
}.map{|opt|
'--disable-' + opt
}
opts = OPTIONS.dup
Configs ... | Ruby |
require 'test/unit'
require '../tool/jisx0208'
class Test_JISX0208_Char < Test::Unit::TestCase
def test_create_with_row_cell
assert_equal JISX0208::Char.new(0x2121), JISX0208::Char.new(1, 1)
end
def test_succ
assert_equal JISX0208::Char.new(0x2221), JISX0208::Char.new(0x217e).succ
assert_equal JISX... | Ruby |
#!/usr/bin/env ruby
# example:
# ./enc-emoji4unicode.rb emoji4unicode.xml > ../enc/trans/emoji-exchange-tbl.rb
require 'rexml/document'
require File.expand_path("../transcode-tblgen", __FILE__)
class EmojiTable
VERBOSE_MODE = false
def initialize(xml_path)
@doc = REXML::Document.new File.open(xml_path)
... | Ruby |
#!/usr/bin/env ruby
###
### mdoc2man - mdoc to man converter
###
### Quick usage: mdoc2man.rb < mdoc_manpage.8 > man_manpage.8
###
### Ported from Perl by Akinori MUSHA.
###
### Copyright (c) 2001 University of Illinois Board of Trustees
### Copyright (c) 2001 Mark D. Roth
### Copyright (c) 2002, 2003 Akinori MUSHA... | Ruby |
#!ruby
source = ARGF.read
source = source.gsub(%r{/\*([!*])((?!\*/).+?)\*/}m) do |comment|
marker, comment = $1, $2
next "/**#{comment}*/" unless /^\s*\*\s?\-\-\s*$/ =~ comment
doxybody = nil
comment.each_line do |line|
if doxybody
if /^\s*\*\s?\+\+\s*$/ =~ line
break
end
doxybody... | Ruby |
require 'erb'
require 'optparse'
require 'fileutils'
timestamp = nil
output = nil
ifchange = nil
opt = OptionParser.new do |o|
o.on('-t', '--timestamp[=PATH]') {|v| timestamp = v || true}
o.on('-o', '--output=PATH') {|v| output = v}
o.on('-c', '--[no-]if-change') {|v| ifchange = v}
o.order!(ARGV)
end
template ... | Ruby |
module JISX0208
class Char
class << self
def from_sjis(sjis)
unless 0x8140 <= sjis && sjis <= 0xFCFC
raise ArgumentError, "out of the range of JIS X 0208: 0x#{sjis.to_s(16)}"
end
sjis_hi, sjis_lo = sjis >> 8, sjis & 0xFF
sjis_hi = (sjis_hi - ((sjis_hi <= 0x9F) ? 0x8... | Ruby |
# ARGF = open('ha')
cd = `pwd`.chomp + '/'
ARGF.each{|line|
if /^0x([a-z0-9]+),/ =~ line
stat = line.split(',')
addr = stat[0].hex + 0x00400000
retired = stat[2].to_i
ticks = stat[3].to_i
src = `addr2line -e miniruby.exe #{addr.to_s(16)}`.chomp
src.sub!(cd, '')
puts '%-40s 0x%08x %8d %8... | Ruby |
#! /bin/ruby
# This needs ruby 1.9 and subversion.
# run this in a repository to commit.
require 'date'
require 'tempfile'
$repos = 'svn+ssh://svn@ci.ruby-lang.org/ruby/'
ENV['LC_ALL'] = 'C'
def help
puts <<-end
simple backport
ruby #$0 1234
range backport
ruby #$0 1234:5678
backport from other branch
ruby... | Ruby |
# This file is interpreted by $(BASERUBY) and miniruby.
# $(BASERUBY) is used for miniprelude.c.
# miniruby is used for prelude.c.
# Since $(BASERUBY) may be older than Ruby 1.9,
# Ruby 1.9 feature should not be used.
require 'erb'
class Prelude
SRCDIR = File.dirname(File.dirname(__FILE__))
$:.unshift(SRCDIR)
... | Ruby |
require 'optparse'
require 'erb'
require 'fileutils'
require 'pp'
class Array
unless [].respond_to? :product
def product(*args)
if args.empty?
self.map {|e| [e] }
else
result = []
self.each {|e0|
result.concat args.first.product(*args[1..-1]).map {|es| [e0, *es] }
... | Ruby |
#!/usr/bin/env ruby
ENV.delete('PWD')
require 'optparse'
unless File.respond_to? :realpath
require 'pathname'
def File.realpath(arg)
Pathname(arg).realpath.to_s
end
end
Program = $0
class VCS
class NotFoundError < RuntimeError; end
@@dirs = []
def self.register(dir)
@@dirs << [dir, self]
end... | Ruby |
#!/usr/bin/env ruby
# Creates the data structures needed by Onigurma to map Unicode codepoints to
# property names and POSIX character classes
#
# To use this, get UnicodeData.txt, Scripts.txt, PropList.txt,
# PropertyAliases.txt, PropertyValueAliases.txt, DerivedCoreProperties.txt,
# and DerivedAge.txt from unicode.... | Ruby |
#!./miniruby
show = false
precommand = []
while arg = ARGV[0]
break ARGV.shift if arg == '--'
/\A--([-\w]+)(?:=(.*))?\z/ =~ arg or break
arg, value = $1, $2
re = Regexp.new('\A'+arg.gsub(/\w+\b/, '\&\\w*')+'\z', "i")
case
when re =~ "srcdir"
srcdir = value
when re =~ "archdir"
archdir = value
w... | Ruby |
#! ./miniruby
exit if defined?(CROSS_COMPILING)
ruby = ENV["RUBY"]
unless ruby
load './rbconfig.rb'
ruby = "./#{RbConfig::CONFIG['ruby_install_name']}#{RbConfig::CONFIG['EXEEXT']}"
end
unless File.exist? ruby
print "#{ruby} is not found.\n"
print "Try `make' first, then `make test', please.\n"
exit false
end... | Ruby |
#!./miniruby
begin
load "./rbconfig.rb"
rescue LoadError
CONFIG = Hash.new {""}
else
include RbConfig
$".unshift File.expand_path("./rbconfig.rb")
end
srcdir = File.expand_path('../..', __FILE__)
unless defined?(CROSS_COMPILING) and CROSS_COMPILING
$:.replace([srcdir+"/lib", Dir.pwd])
end
require 'fileutils... | Ruby |
#!/usr/bin/ruby -s
# -*- coding: us-ascii -*-
require 'uri'
require 'digest/md5'
require 'digest/sha2'
require 'fileutils'
require 'tmpdir'
STDOUT.sync = true
$exported = nil if $exported == ""
$archname = nil if $archname == ""
$keep_temp ||= nil
$patch_file ||= nil
def usage
<<USAGE
usage: #{File.basename $0} [op... | Ruby |
stat = {}
while line = ARGF.gets
if /\[start\] (\w+)/ =~ line
name = $1
puts '--------------------------------------------------------------'
puts line
size = 0
len = 0
while line = ARGF.gets
if /\[start\] (\w+)/ =~ line
puts "\t; # length: #{len}, size: #{size}"
puts ... | Ruby |
#!./miniruby -s
# avoid warnings with -d.
$install_name ||= nil
$so_name ||= nil
srcdir = File.expand_path('../..', __FILE__)
$:.replace [srcdir+"/lib"] unless defined?(CROSS_COMPILING)
$:.unshift(".")
require "fileutils"
mkconfig = File.basename($0)
rbconfig_rb = ARGV[0] || 'rbconfig.rb'
unless File.directory?(dir... | Ruby |
#!ruby
require 'optparse'
Version = %w$Revision: 11626 $[1..-1]
require "#{File.join(File.dirname(__FILE__), 'instruction')}"
if $0 == __FILE__
opts = ARGV.options
maker = RubyVM::SourceCodeGenerator.def_options(opts)
files = opts.parse!
generator = maker.call
generator.generate(files)
end
| Ruby |
require File.expand_path('../jisx0208', __FILE__)
ENCODES = [
{
:name => "SHIFT_JIS-DOCOMO",
:src_zone => [0xF8..0xFC, 0x40..0xFC, 8],
:dst_ilseq => 0xFFFE,
:map => [
[0xE63E..0xE757, JISX0208::Char.from_sjis(0xF89F)],
],
},
{
:name => "ISO-2022-JP-KDDI",
:src_zone => [0x21..0x7... | Ruby |
#!./miniruby
#
#
require 'erb'
class RubyVM
class Instruction
def initialize name, opes, pops, rets, comm, body, tvars, sp_inc,
orig = self, defopes = [], type = nil,
nsc = [], psc = [[], []]
@name = name
@opes = opes # [[type, name], ...]
@pops = pops # ... | Ruby |
"exec" "${RUBY-ruby}" "-x" "$0" "$@"; true # -*- mode: ruby; coding: utf-8 -*-
#!./ruby
# $Id: runner.rb 32088 2011-06-14 14:17:42Z akr $
# NOTE:
# Never use optparse in this file.
# Never use test/unit in this file.
# Never use Ruby extensions in this file.
begin
require 'fileutils'
require 'tmpdir'
rescue LoadE... | Ruby |
assert_equal %q{[1, 2, 4, 5, 6, 7, 8]}, %q{$a = []; begin; ; $a << 1
[1,2].each{; $a << 2
break; $a << 3
}; $a << 4
begin; $a << 5
ensure; $a << 6
end; $a << 7
; $a << 8
; rescue Exception; $a << 99; end; $a}
assert_equal %q{[1, 2, 3, 5, 6, 7, 8]}, %q{$a = []; begin; ; $a << 1
begin; $a << 2
[1,2]... | Ruby |
assert_equal %q{ok}, %q{
def m
a = :ok
$b = binding
end
m
eval('a', $b)
}
assert_equal %q{[:ok, :ok2]}, %q{
def m
a = :ok
$b = binding
end
m
eval('b = :ok2', $b)
eval('[a, b]', $b)
}
assert_equal %q{[nil, 1]}, %q{
$ans = []
def m
$b = binding
end
m
$ans << eval(%q{
$a... | Ruby |
# class
assert_equal 'true', %q( class C; end
Object.const_defined?(:C) )
assert_equal 'Class', %q( class C; end
C.class )
assert_equal 'C', %q( class C; end
C.name )
assert_equal 'C', %q( class C; end
... | Ruby |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.